From 8782c0da7243fb6c608e6a00fd90957423832481 Mon Sep 17 00:00:00 2001 From: Madhavan Srinivasan Date: Mon, 11 Sep 2017 13:43:57 +0530 Subject: [PATCH] skiboot/hw/imc: Add NULL pointer check Minor cleanup to avoid null pointer access. Signed-off-by: Madhavan Srinivasan Signed-off-by: Stewart Smith --- 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;