提交 d7cc2520 编写于 作者: A Alex Jia 提交者: Eric Blake

uml: Plug memory leak on umlStartVMDaemon() error path

Detected by Coverity.  Leak introduced in commit 8866eed0.

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: NAlex Jia <ajia@redhat.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 773a4ea5
...@@ -1040,12 +1040,8 @@ static int umlStartVMDaemon(virConnectPtr conn, ...@@ -1040,12 +1040,8 @@ static int umlStartVMDaemon(virConnectPtr conn,
return -1; return -1;
} }
if (!(cmd = umlBuildCommandLine(conn, driver, vm))) { if (!(cmd = umlBuildCommandLine(conn, driver, vm)))
VIR_FORCE_CLOSE(logfd); goto cleanup;
virDomainConfVMNWFilterTeardown(vm);
umlCleanupTapDevices(vm);
return -1;
}
for (i = 0 ; i < vm->def->nconsoles ; i++) { for (i = 0 ; i < vm->def->nconsoles ; i++) {
VIR_FREE(vm->def->consoles[i]->info.alias); VIR_FREE(vm->def->consoles[i]->info.alias);
...@@ -1065,16 +1061,16 @@ static int umlStartVMDaemon(virConnectPtr conn, ...@@ -1065,16 +1061,16 @@ static int umlStartVMDaemon(virConnectPtr conn,
virCommandDaemonize(cmd); virCommandDaemonize(cmd);
ret = virCommandRun(cmd, NULL); ret = virCommandRun(cmd, NULL);
VIR_FORCE_CLOSE(logfd);
if (ret < 0) if (ret < 0)
goto cleanup; goto cleanup;
if (autoDestroy && if (autoDestroy &&
umlProcessAutoDestroyAdd(driver, vm, conn) < 0) (ret = umlProcessAutoDestroyAdd(driver, vm, conn)) < 0)
goto cleanup; goto cleanup;
ret = virDomainObjSetDefTransient(driver->caps, vm, false); ret = virDomainObjSetDefTransient(driver->caps, vm, false);
cleanup: cleanup:
VIR_FORCE_CLOSE(logfd);
virCommandFree(cmd); virCommandFree(cmd);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册