[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 13/21] spapr: fix potential memory leak in spapr_core_p
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 13/21] spapr: fix potential memory leak in spapr_core_plug() |
Date: |
Mon, 17 Jul 2017 16:56:13 +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 16d450f21c..a58dd54392 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.3
- [Qemu-ppc] [PULL 05/21] spapr: Remove 'awaiting_allocation' DRC flag, (continued)
- [Qemu-ppc] [PULL 05/21] spapr: Remove 'awaiting_allocation' DRC flag, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 01/21] spapr: Remove unnecessary instance_size specifications from DRC subtypes, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 09/21] spapr: Cleanups relating to DRC awaiting_release field, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 12/21] spapr: Implement DR-indicator for physical DRCs only, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 19/21] pseries: Allow HPT resizing with KVM, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 06/21] spapr: Simplify unplug path, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 02/21] spapr: migrate pending_events of spapr state, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 08/21] spapr: Refactor spapr_drc_detach(), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 03/21] spapr: Minor cleanups to events handling, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 17/21] pseries: Enable HPT resizing for 2.10, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 13/21] spapr: fix potential memory leak in spapr_core_plug(),
David Gibson <=
- [Qemu-ppc] [PULL 21/21] target/ppc: fix CPU hotplug when radix is enabled (TCG), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 10/21] spapr: Consolidate DRC state variables, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 14/21] ppc/pnv: Remove unused XICSState reference, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 18/21] pseries: Use smaller default hash page tables when guest can resize, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 11/21] spapr: Remove sPAPRConfigureConnectorState sub-structure, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 16/21] pseries: Implement HPT resizing, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 15/21] pseries: Stubs for HPT resizing, David Gibson, 2017/07/17
- Re: [Qemu-ppc] [PULL 00/21] ppc-for-2.10 queue 20170717, Peter Maydell, 2017/07/17