[libvirt] [PATCH] qemu: Fix memory leak in qemuDomainUpdateMemoryDeviceInfo

Yi Wang wang.yi59 at zte.com.cn
Thu May 25 02:20:16 UTC 2017


The @meminfo allocated in qemuMonitorGetMemoryDeviceInfo may be lost when
exit monitor failed. Luckily we can free it according to rc.

Signed-off-by: Yi Wang <wang.yi59 at zte.com.cn>
---
 src/qemu/qemu_domain.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c8dc748..c34ec5a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5767,8 +5767,11 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
 
     rc = qemuMonitorGetMemoryDeviceInfo(priv->mon, &meminfo);
 
-    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+    if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+        if (0 == rc)
+            virHashFree(meminfo);
         return -1;
+    }
 
     /* if qemu doesn't support the info request, just carry on */
     if (rc == -2)
-- 
1.8.3.1





More information about the libvir-list mailing list