]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix a memory leak in virCgroupGetPercpuStats
authorJán Tomko <jtomko@redhat.com>
Mon, 26 Jan 2015 09:20:22 +0000 (10:20 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 26 Jan 2015 15:13:06 +0000 (16:13 +0100)
Coverity reports that my commit af1c98e introduced
two memory leaks:
the cpumap if ncpus == 0 in virCgroupGetPercpuStats
and the params array in the test of the function.

src/util/vircgroup.c
tests/vircgrouptest.c

index e65617a8a437fb1246131eae81fd7f7a879e40e5..6957e81d547227a05e35efd6c96b0d6c138ed199 100644 (file)
@@ -3061,8 +3061,10 @@ virCgroupGetPercpuStats(virCgroupPtr group,
 
     total_cpus = virBitmapSize(cpumap);
 
-    if (ncpus == 0)
-        return total_cpus;
+    if (ncpus == 0) {
+        rv = total_cpus;
+        goto cleanup;
+    }
 
     if (start_cpu >= total_cpus) {
         virReportError(VIR_ERR_INVALID_ARG,
index a455a8101ab6bf06c114bbf46f35bbca3a5f47c4..cc1825bb2456d208f1924bb3c5e304408e7f37e2 100644 (file)
@@ -614,6 +614,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
 
  cleanup:
     virCgroupFree(&cgroup);
+    VIR_FREE(params);
     return ret;
 }