render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From ed02ed00086992e3e7445a2938fe5ef5006781f3 Mon Sep 17 00:00:00 2001
Message-Id: <ed02ed00086992e3e7445a2938fe5ef5006781f3.1381871411.git.jdenemar@redhat.com>
From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Mon, 7 Oct 2013 17:17:32 +0100
Subject: [PATCH] Free cmd in virNetDevVethDelete

For

  https://bugzilla.redhat.com/show_bug.cgi?id=1014604

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
(cherry picked from commit 524b21979a59b825c5547717bcb38b5e3ff0fa67)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virnetdevveth.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index 403961b..ea49053 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -196,18 +196,24 @@ int virNetDevVethDelete(const char *veth)
 {
     virCommandPtr cmd = virCommandNewArgList("ip", "link", "del", veth, NULL);
     int status;
+    int ret = -1;
 
     if (virCommandRun(cmd, &status) < 0)
-        return -1;
+        goto cleanup;
 
     if (status != 0) {
         if (!virNetDevExists(veth)) {
             VIR_DEBUG("Device %s already deleted (by kernel namespace cleanup)", veth);
-            return 0;
+            ret = 0;
+            goto cleanup;
         }
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to delete veth device %s"), veth);
-        return -1;
+        goto cleanup;
     }
-    return 0;
+
+    ret = 0;
+cleanup:
+    virCommandFree(cmd);
+    return ret;
 }
-- 
1.8.3.2