mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
Fix a memory leak in virCgroupGetPercpuStats
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -614,6 +614,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
|
||||
|
||||
cleanup:
|
||||
virCgroupFree(&cgroup);
|
||||
VIR_FREE(params);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user