[libvirt PATCH v6 11/15] xen_xm: Adapt xenParseXMOS due to changes in xenConfigGetString

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

 



xenConfigGetString returns a newly-allocated pointer and it has to be
freed by the caller.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 src/xenconfig/xen_xm.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c
index 7b60f25ec1..a476401183 100644
--- a/src/xenconfig/xen_xm.c
+++ b/src/xenconfig/xen_xm.c
@@ -42,16 +42,16 @@ static int
 xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
 {
     size_t i;
+    int ret = -1;
+    const char *boot = NULL, *extra = NULL, *root = NULL;
 
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
-        const char *boot;
-
         if (VIR_ALLOC(def->os.loader) < 0 ||
             xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0)
-            return -1;
+            goto cleanup;
 
         if (xenConfigGetString(conf, "boot", &boot, "c") < 0)
-            return -1;
+            goto cleanup;
 
         for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) {
             switch (boot[i]) {
@@ -72,38 +72,42 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
             def->os.nBootDevs++;
         }
     } else {
-        const char *extra, *root;
-
         if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0)
-            return -1;
+            goto cleanup;
         if (xenConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0)
-            return -1;
+            goto cleanup;
 
         if (xenConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0)
-            return -1;
+            goto cleanup;
 
         if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0)
-            return -1;
+            goto cleanup;
 
         if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
-            return -1;
+            goto cleanup;
 
         if (xenConfigGetString(conf, "root", &root, NULL) < 0)
-            return -1;
+            goto cleanup;
 
         if (root && extra) {
             if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0)
-                return -1;
+                goto cleanup;
         } else if (root) {
             if (virAsprintf(&def->os.cmdline, "root=%s", root) < 0)
-                return -1;
+                goto cleanup;
         } else if (extra) {
             if (VIR_STRDUP(def->os.cmdline, extra) < 0)
-                return -1;
+                goto cleanup;
         }
     }
 
-    return 0;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(extra);
+    VIR_FREE(root);
+    VIR_FREE(boot);
+    return ret;
 }
 
 
-- 
2.17.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