[Skiboot] [PATCH] skiboot/hw/imc: Add NULL pointer check

Madhavan Srinivasan maddy at linux.vnet.ibm.com
Mon Sep 11 18:13:57 AEST 2017


Minor cleanup to avoid null pointer access.

Signed-off-by: Madhavan Srinivasan <maddy at linux.vnet.ibm.com>
---
 hw/imc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/imc.c b/hw/imc.c
index 3db67a2a9d34..ccf3973c4752 100644
--- a/hw/imc.c
+++ b/hw/imc.c
@@ -599,6 +599,8 @@ static int64_t opal_imc_counters_start(uint32_t type, uint64_t cpu_pir)
 	case OPAL_IMC_COUNTERS_NEST:
 		/* Fetch the IMC control block structure */
 		cb = get_imc_cb(c->chip_id);
+		if (!cb)
+			return OPAL_HARDWARE;
 
 		/* Set the run command */
 		op = NEST_IMC_ENABLE;
@@ -651,6 +653,8 @@ static int64_t opal_imc_counters_stop(uint32_t type, uint64_t cpu_pir)
 	case OPAL_IMC_COUNTERS_NEST:
 		/* Fetch the IMC control block structure */
 		cb = get_imc_cb(c->chip_id);
+		if (!cb)
+			return OPAL_HARDWARE;
 
 		/* Set the run command */
 		op = NEST_IMC_DISABLE;
-- 
2.7.4



More information about the Skiboot mailing list