[libvirt] [PATCH 07/11] xend: Fix a memory leak found by Coverity

John Ferlan jferlan at redhat.com
Wed Jan 30 18:51:42 UTC 2013


Commit id '87b4c10c' moved the VIR_ALLOC_N, but didn't check if 'cpuset'
had been allocated on failure.
---
 src/xen/xend_internal.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index a8e276d..51f1f15 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1130,8 +1130,10 @@ sexpr_to_xend_topology(const struct sexpr *root,
                 goto error;
         }
 
-        if (VIR_ALLOC_N(cpuInfo, numCpus) < 0)
+        if (VIR_ALLOC_N(cpuInfo, numCpus) < 0) {
+            virBitmapFree(cpuset);
             goto memory_error;
+        }
 
         for (n = 0, cpu = 0; cpu < numCpus; cpu++) {
             bool used;
-- 
1.7.11.7




More information about the libvir-list mailing list