[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 12/18] spapr: fix potential memory leak in spapr_core_p
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 12/18] spapr: fix potential memory leak in spapr_core_plug() |
Date: |
Fri, 14 Jul 2017 16:15:15 +1000 |
From: Greg Kurz <address@hidden>
Since commit 5c1da81215c7 ("spapr: Remove unnecessary differences between
hotplug and coldplug paths"), the CPU DT for the DRC is always allocated.
This causes a memory leak for pseries-2.6 and older machine types, that
don't support CPU hotplug and don't allocate DRCs for CPUs.
Reported-by: Bharata B Rao <address@hidden>
Signed-off-by: Greg Kurz <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e43d1b2ea2..396c3340cb 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2974,8 +2974,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev,
DeviceState *dev,
CPUState *cs = CPU(core->threads);
sPAPRDRConnector *drc;
Error *local_err = NULL;
- void *fdt = NULL;
- int fdt_offset = 0;
int smt = kvmppc_smt_threads();
CPUArchId *core_slot;
int index;
@@ -2991,9 +2989,12 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev,
DeviceState *dev,
g_assert(drc || !mc->has_hotpluggable_cpus);
- fdt = spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr);
-
if (drc) {
+ void *fdt;
+ int fdt_offset;
+
+ fdt = spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr);
+
spapr_drc_attach(drc, dev, fdt, fdt_offset, &local_err);
if (local_err) {
g_free(fdt);
--
2.13.0
- [Qemu-ppc] [PULL 06/18] spapr: Abort on delete failure in spapr_drc_release(), (continued)
- [Qemu-ppc] [PULL 06/18] spapr: Abort on delete failure in spapr_drc_release(), David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 13/18] ppc/pnv: Remove unused XICSState reference, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 04/18] spapr: Remove 'awaiting_allocation' DRC flag, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 07/18] spapr: Refactor spapr_drc_detach(), David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 03/18] spapr: Treat devices added before inbound migration as coldplugged, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 16/18] pseries: Enable HPT resizing for 2.10, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 01/18] spapr: migrate pending_events of spapr state, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 11/18] spapr: Implement DR-indicator for physical DRCs only, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 14/18] pseries: Stubs for HPT resizing, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 15/18] pseries: Implement HPT resizing, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 12/18] spapr: fix potential memory leak in spapr_core_plug(),
David Gibson <=
- [Qemu-ppc] [PULL 05/18] spapr: Simplify unplug path, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 08/18] spapr: Cleanups relating to DRC awaiting_release field, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 18/18] pseries: Allow HPT resizing with KVM, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 10/18] spapr: Remove sPAPRConfigureConnectorState sub-structure, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 17/18] pseries: Use smaller default hash page tables when guest can resize, David Gibson, 2017/07/14
- [Qemu-ppc] [PULL 09/18] spapr: Consolidate DRC state variables, David Gibson, 2017/07/14
- Re: [Qemu-ppc] [PULL 00/18] ppc-for-2.10 queue 20170714, Peter Maydell, 2017/07/14
- Re: [Qemu-ppc] [PULL 00/18] ppc-for-2.10 queue 20170714, Peter Maydell, 2017/07/14