[PATCH 09/11] qemuBuildControllersByTypeCommandLine: free devstr in the cleanup section

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 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 7aafe235e2..5c7e53bb6a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3117,12 +3117,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;
@@ -3155,23 +3155,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;
 }
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux