spapr: ensure core_slot isn't NULL in spapr_core_unplug()
authorGreg Kurz <groug@kaod.org>
Thu, 18 May 2017 13:58:31 +0000 (15:58 +0200)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 24 May 2017 01:39:53 +0000 (11:39 +1000)
If we go that far on the path of hot-removing a core and we find out that
the core-id is invalid, then we have a serious bug.

Let's make it explicit with an assert() instead of dereferencing a NULL
pointer.

This fixes Coverity issue CID 1375404.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr.c

index 35dceb024eb073370fa0fdf99e90ffb8627c932c..c912eaa2befa8aa72db6b45c899b9a3647a39a4d 100644 (file)
@@ -2725,6 +2725,7 @@ static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
     CPUCore *cc = CPU_CORE(dev);
     CPUArchId *core_slot = spapr_find_cpu_slot(ms, cc->core_id, NULL);
 
+    assert(core_slot);
     core_slot->cpu = NULL;
     object_unparent(OBJECT(dev));
 }