[libvirt PATCH 3/3] virQEMUCapsSetHostModel: Fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virQEMUCapsSetHostModel is called by virQEMUCapsInitHostCPUModel,
which in turn is typically called twice (for KVM and QEMU), e.g. in
virQEMUCapsLoadCache and virQEMUCapsNewForBinaryInternal.

The second call leaks memory pointed to by "reported", "migratable"
and "full".

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f1a3c526ef..ff8877631c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2276,6 +2276,14 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps,
     virQEMUCapsHostCPUData *cpuData;
 
     cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU;
+
+    if (cpuData->reported)
+        virCPUDefFree(cpuData->reported);
+    if (cpuData->migratable)
+        virCPUDefFree(cpuData->migratable);
+    if (cpuData->full)
+        virCPUDefFree(cpuData->full);
+
     cpuData->reported = reported;
     cpuData->migratable = migratable;
     cpuData->full = full;
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux