mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
495accb047
commit
b54f48812d
|
@ -3061,8 +3061,10 @@ virCgroupGetPercpuStats(virCgroupPtr group,
|
||||||
|
|
||||||
total_cpus = virBitmapSize(cpumap);
|
total_cpus = virBitmapSize(cpumap);
|
||||||
|
|
||||||
if (ncpus == 0)
|
if (ncpus == 0) {
|
||||||
return total_cpus;
|
rv = total_cpus;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (start_cpu >= total_cpus) {
|
if (start_cpu >= total_cpus) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
|
|
@ -614,6 +614,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCgroupFree(&cgroup);
|
virCgroupFree(&cgroup);
|
||||||
|
VIR_FREE(params);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue