]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Fix memory leak in qemuProcessStart
authorJiri Denemark <jdenemar@redhat.com>
Tue, 20 Oct 2015 12:40:42 +0000 (14:40 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 4 Nov 2015 12:09:35 +0000 (13:09 +0100)
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@redhat.com>
src/qemu/qemu_process.c

index 92eab3ca300999f0760017221e843b277f7e5290..524072c6e18289fa05e4bc08cf8ff3099d830c5e 100644 (file)
@@ -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);