[libvirt] [PATCH 1/2] virsh: perf: Don't leak domain

Peter Krempa pkrempa at redhat.com
Thu Apr 21 07:56:19 UTC 2016


After failing to parse the perf event list, the code would return
failure without freeing the previously acquired object. Rearrange the
code to avoid the problem.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329046
---
 tools/virsh-domain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a1d4a75..4a73a80 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8623,13 +8623,13 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;

-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
-        return false;
-
     if (vshCommandOptStringReq(ctl, cmd, "enable", &enable) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0)
         return false;

+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
     if (enable && virshParseEventStr(enable, true, &params,
                                      &nparams, &maxparams) < 0)
         goto cleanup;
-- 
2.8.1




More information about the libvir-list mailing list