aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharata B Rao <bharata@linux.vnet.ibm.com>2017-06-16 07:07:53 +0530
committerDavid Gibson <david@gibson.dropbear.id.au>2017-06-30 14:03:31 +1000
commit6595ab31583ed3ca4a7820dc888fe2de3c37c8a2 (patch)
treea75926388825be3656f68458e2c516ac01c290e4
parentfd356563683216cf3668a79388450747f6d1373b (diff)
downloadqemu-6595ab31583ed3ca4a7820dc888fe2de3c37c8a2.zip
qemu-6595ab31583ed3ca4a7820dc888fe2de3c37c8a2.tar.gz
qemu-6595ab31583ed3ca4a7820dc888fe2de3c37c8a2.tar.bz2
spapr: prevent QEMU crash when CPU realization fails
ICPState objects were being allocated before CPU thread realization. However commit 9ed656631d73 (xics: setup cpu at realize time) reversed it by allocating ICPState objects after CPU thread is realized. But it didn't take care to fix the error path because of which we observe a SIGSEGV when CPU thread realization fails during cold/hotplug. Fix this by ensuring that we do object_unparent() of ICPState object only in case when is was created earlier. Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--hw/ppc/spapr_cpu_core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index d6719d5..ea278ce 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -178,7 +178,7 @@ static void spapr_cpu_core_realize_child(Object *child, Error **errp)
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
CPUState *cs = CPU(child);
PowerPCCPU *cpu = POWERPC_CPU(cs);
- Object *obj = NULL;
+ Object *obj;
object_property_set_bool(child, true, "realized", &local_err);
if (local_err) {
@@ -198,13 +198,14 @@ static void spapr_cpu_core_realize_child(Object *child, Error **errp)
object_property_add_const_link(obj, ICP_PROP_CPU, child, &error_abort);
object_property_set_bool(obj, true, "realized", &local_err);
if (local_err) {
- goto error;
+ goto free_icp;
}
return;
-error:
+free_icp:
object_unparent(obj);
+error:
error_propagate(errp, local_err);
}