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

Signed-off-by: Fabiano Fidêncio <fiden...@redhat.com>
---
 src/xenconfig/xen_xm.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c
index a476401183..4bff727e04 100644
--- a/src/xenconfig/xen_xm.c
+++ b/src/xenconfig/xen_xm.c
@@ -422,17 +422,18 @@ static int
 xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def)
 {
     const char *str;
+    int ret = -1;
 
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0)
-            return -1;
+            goto cleanup;
         if (str &&
                 (STREQ(str, "tablet") ||
                  STREQ(str, "mouse") ||
                  STREQ(str, "keyboard"))) {
             virDomainInputDefPtr input;
             if (VIR_ALLOC(input) < 0)
-                return -1;
+                goto cleanup;
 
             input->bus = VIR_DOMAIN_INPUT_BUS_USB;
             if (STREQ(str, "mouse"))
@@ -443,11 +444,14 @@ xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def)
                 input->type = VIR_DOMAIN_INPUT_TYPE_KBD;
             if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) {
                 virDomainInputDefFree(input);
-                return -1;
+                goto cleanup;
             }
         }
     }
-    return 0;
+    ret = 0;
+
+ cleanup:
+    return ret;
 }
 
 /*
-- 
2.17.1

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

Reply via email to