]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuBuildControllersByTypeCommandLine: free devstr in the cleanup
authorJán Tomko <jtomko@redhat.com>
Tue, 15 Jan 2019 16:59:17 +0000 (17:59 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 25 Jan 2019 13:58:43 +0000 (14:58 +0100)
section

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/qemu/qemu_command.c

index 361a345fe5c31fefa6d751f17a9562128f0ff6ad..21823fdd1205906dfbf4b2133b0e5c135f8c5ec5 100644 (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;
 }