From 524b21979a59b825c5547717bcb38b5e3ff0fa67 Mon Sep 17 00:00:00 2001 From: Gao feng Date: Fri, 4 Oct 2013 18:53:52 +0800 Subject: [PATCH] Free cmd in virNetDevVethDelete Signed-off-by: Gao feng --- 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 403961bf53..ea49053a22 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; }