[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 23/28] spapr_cpu_core: fix potential leak in spapr_cpu_
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 23/28] spapr_cpu_core: fix potential leak in spapr_cpu_core_realize() |
Date: |
Mon, 18 Jun 2018 13:53:19 +1000 |
From: Greg Kurz <address@hidden>
Commit 94ad93bd97684 (QEMU 2.12) switched to instantiate CPUs separately
but it missed to adapt the error path accordingly. If something fails in
the CPU creation loop, then the CPU object that was just created is leaked.
The error paths in this function are a bit obfuscated, and adding
yet another label to free this CPU object makes it worse. We should
move the block of the loop to a separate function, with a proper
rollback path, but this is a bigger cleanup.
For now, let's just fix the bug by adding the missing calls to
object_unref(). This will allow easier backport to older QEMU
versions.
Signed-off-by: Greg Kurz <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_cpu_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index ad404d13ec..a9bb2d61e8 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -187,6 +187,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error
**errp)
cs->cpu_index = cc->core_id + i;
spapr_set_vcpu_id(cpu, cs->cpu_index, &local_err);
if (local_err) {
+ object_unref(obj);
goto err;
}
@@ -198,6 +199,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error
**errp)
object_property_add_child(OBJECT(sc), id, obj, &local_err);
g_free(id);
if (local_err) {
+ object_unref(obj);
goto err;
}
object_unref(obj);
--
2.17.1
- [Qemu-ppc] [PULL 16/28] sm501: Do not clear read only bits when writing registers, (continued)
- [Qemu-ppc] [PULL 16/28] sm501: Do not clear read only bits when writing registers, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 18/28] pnv: Fix some error handling cpu realize(), David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 19/28] pnv_core: Allocate cpu thread objects individually, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 10/28] adb: add property to disable direct reg 3 writes, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 05/28] ppc: introduce Core99MachinesState for the mac99 machine, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 22/28] spapr_cpu_core: convert last snprintf() to g_strdup_printf(), David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 27/28] target/ppc, spapr: Move VPA information to machine_data, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 06/28] mac_newworld: add via machine option to control mac99 VIA/ADB configuration, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 24/28] spapr_cpu_core: add missing rollback on realization path, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 12/28] xics_kvm: fix a build break, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 23/28] spapr_cpu_core: fix potential leak in spapr_cpu_core_realize(),
David Gibson <=
- [Qemu-ppc] [PULL 21/28] pnv: Add cpu unrealize path, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 17/28] spapr: Clean up cpu realize/unrealize paths, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 07/28] mac_newworld: add gpios to macio devices with PMU enabled, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 28/28] spapr: fix xics_system_init() error path, David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 25/28] spapr_cpu_core: introduce spapr_create_vcpu(), David Gibson, 2018/06/17
- [Qemu-ppc] [PULL 11/28] mac_newworld: add PMU device, David Gibson, 2018/06/17
- Re: [Qemu-ppc] [PULL 00/28] ppc-for-3.0 queue 20180618, Peter Maydell, 2018/06/19