[libvirt] [PATCH 5/5] qemu: Fix memory leak in qemuProcessStart

Jiri Denemark jdenemar at redhat.com
Tue Oct 27 15:27:42 UTC 2015


nodeset should be freed in both success and failure paths.

While tmppath is freed immediately after it's consumed, moving it from
error to cleanup label is a bit more consistent and robust.

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/qemu/qemu_process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 92eab3c..524072c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5104,14 +5104,14 @@ int qemuProcessStart(virConnectPtr conn,
     virObjectUnref(cfg);
     virObjectUnref(caps);
     VIR_FREE(nicindexes);
+    VIR_FREE(nodeset);
+    VIR_FREE(tmppath);
     return ret;
 
  error:
     /* We jump here if we failed to start the VM for any reason, or
      * if we failed to initialize the now running VM. kill it off and
      * pretend we never started it */
-    VIR_FREE(tmppath);
-    VIR_FREE(nodeset);
     if (priv->mon)
         qemuMonitorSetDomainLog(priv->mon, -1);
     qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, stop_flags);
-- 
2.6.2




More information about the libvir-list mailing list