]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
uml: Plug memory leak on umlStartVMDaemon() error path
authorAlex Jia <ajia@redhat.com>
Wed, 30 Nov 2011 05:57:10 +0000 (13:57 +0800)
committerEric Blake <eblake@redhat.com>
Wed, 30 Nov 2011 23:37:35 +0000 (16:37 -0700)
Detected by Coverity.  Leak introduced in commit 8866eed.

Two bugs here:
1. logfd wasn't closed on all return paths
2. if we failed to mark a domain autodestroy, then the domain
was not made transient but we still returned success

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
src/uml/uml_driver.c

index 073f3620dec70bc72d889319b6c7a0ff11c09bd8..faea313f6db9a897726b04211dc4d43eb0f2fee3 100644 (file)
@@ -1040,12 +1040,8 @@ static int umlStartVMDaemon(virConnectPtr conn,
         return -1;
     }
 
-    if (!(cmd = umlBuildCommandLine(conn, driver, vm))) {
-        VIR_FORCE_CLOSE(logfd);
-        virDomainConfVMNWFilterTeardown(vm);
-        umlCleanupTapDevices(vm);
-        return -1;
-    }
+    if (!(cmd = umlBuildCommandLine(conn, driver, vm)))
+        goto cleanup;
 
     for (i = 0 ; i < vm->def->nconsoles ; i++) {
         VIR_FREE(vm->def->consoles[i]->info.alias);
@@ -1065,16 +1061,16 @@ static int umlStartVMDaemon(virConnectPtr conn,
     virCommandDaemonize(cmd);
 
     ret = virCommandRun(cmd, NULL);
-    VIR_FORCE_CLOSE(logfd);
     if (ret < 0)
         goto cleanup;
 
     if (autoDestroy &&
-        umlProcessAutoDestroyAdd(driver, vm, conn) < 0)
+        (ret = umlProcessAutoDestroyAdd(driver, vm, conn)) < 0)
         goto cleanup;
 
     ret = virDomainObjSetDefTransient(driver->caps, vm, false);
 cleanup:
+    VIR_FORCE_CLOSE(logfd);
     virCommandFree(cmd);
 
     if (ret < 0) {