[PATCH 1/2] free cmd in virNetDevVethDelete

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

 



Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
---
 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

--
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]