[PATCH 2/2] free cmd in virNetDevVethCreate

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

 



Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
---
 src/util/virnetdevveth.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index 1085217..2d727f1 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -110,6 +110,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
     char *veth1auto = NULL;
     char *veth2auto = NULL;
     int vethNum = 0;
+    virCommandPtr cmd = NULL;
     size_t i;
 
     /*
@@ -139,7 +140,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
             vethNum = veth2num + 1;
         }
 
-        virCommandPtr cmd = virCommandNew("ip");
+        cmd = virCommandNew("ip");
         virCommandAddArgList(cmd, "link", "add",
                              *veth1 ? *veth1 : veth1auto,
                              "type", "veth", "peer", "name",
@@ -169,6 +170,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
                   status);
         VIR_FREE(veth1auto);
         VIR_FREE(veth2auto);
+        virCommandFree(cmd);
     }
 
     virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -176,6 +178,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
                    MAX_VETH_RETRIES);
 
 cleanup:
+    virCommandFree(cmd);
     VIR_FREE(veth1auto);
     VIR_FREE(veth2auto);
     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]