qemuBuildControllersByTypeCommandLine: free devstr in the cleanup

section

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Ján Tomko 2019-01-15 17:59:17 +01:00
parent c7e03df8c0
commit fc1c16bccd

View File

@ -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;
}