From fc1c16bccd4deb86848a3f37ccb55831ed8ce2f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 15 Jan 2019 17:59:17 +0100 Subject: [PATCH] qemuBuildControllersByTypeCommandLine: free devstr in the cleanup section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Cole Robinson --- src/qemu/qemu_command.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 361a345fe5..21823fdd12 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3145,12 +3145,12 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps, virDomainControllerType type) { + char *devstr = NULL; int ret = -1; size_t i; for (i = 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont = def->controllers[i]; - char *devstr; if (cont->type != type) continue; @@ -3183,23 +3183,22 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd, continue; } + VIR_FREE(devstr); if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0) goto cleanup; if (devstr) { - if (qemuCommandAddExtDevice(cmd, &cont->info) < 0) { - VIR_FREE(devstr); + if (qemuCommandAddExtDevice(cmd, &cont->info) < 0) goto cleanup; - } virCommandAddArg(cmd, "-device"); virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); } } ret = 0; cleanup: + VIR_FREE(devstr); return ret; } -- GitLab