[libvirt] [PATCH 1/2] free cmd in virNetDevVethDelete

Gao feng gaofeng at cn.fujitsu.com
Fri Oct 4 10:53:52 UTC 2013


Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
---
 src/util/virnetdevveth.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index 403961b..1085217 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -196,6 +196,7 @@ 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;
@@ -203,11 +204,16 @@ int virNetDevVethDelete(const char *veth)
     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.1




More information about the libvir-list mailing list