Blob Blame History Raw
From 7a032ce726b449746310965777e1b18e531c38b8 Mon Sep 17 00:00:00 2001
Message-Id: <7a032ce726b449746310965777e1b18e531c38b8.1381871411.git.jdenemar@redhat.com>
From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Mon, 7 Oct 2013 17:17:33 +0100
Subject: [PATCH] Free cmd in virNetDevVethCreate

For

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

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
(cherry picked from commit 391b82722ef44df993d21332a06ccdd5e3500306)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virnetdevveth.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index ea49053..25eb282 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,8 @@ int virNetDevVethCreate(char** veth1, char** veth2)
                   status);
         VIR_FREE(veth1auto);
         VIR_FREE(veth2auto);
+        virCommandFree(cmd);
+        cmd = NULL;
     }
 
     virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -176,6 +179,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
                    MAX_VETH_RETRIES);
 
 cleanup:
+    virCommandFree(cmd);
     VIR_FREE(veth1auto);
     VIR_FREE(veth2auto);
     return ret;
-- 
1.8.3.2