mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
qemu: Fix possible memory leak in qemuDomainPinVcpuFlags
During his review of the iothreads pin setting code, Pavel noted that there was a potential memory leak with respect to how the newVcpuPin is handled and the goto endjob's in failure paths which would not free the memory. For reference, See: http://www.redhat.com/archives/libvir-list/2015-March/msg00415.html
This commit is contained in:
parent
4bca6192f2
commit
ffa9f8a19b
@ -5123,10 +5123,10 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
||||
newVcpuPinNum = 0;
|
||||
}
|
||||
|
||||
if (virDomainVcpuPinAdd(&newVcpuPin, &newVcpuPinNum, cpumap, maplen, vcpu) < 0) {
|
||||
if (virDomainVcpuPinAdd(&newVcpuPin, &newVcpuPinNum,
|
||||
cpumap, maplen, vcpu) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to update vcpupin"));
|
||||
virDomainVcpuPinDefArrayFree(newVcpuPin, newVcpuPinNum);
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
@ -5134,7 +5134,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
||||
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||
if (virCgroupNewVcpu(priv->cgroup, vcpu, false, &cgroup_vcpu) < 0)
|
||||
goto endjob;
|
||||
if (qemuSetupCgroupVcpuPin(cgroup_vcpu, newVcpuPin, newVcpuPinNum, vcpu) < 0) {
|
||||
if (qemuSetupCgroupVcpuPin(cgroup_vcpu, newVcpuPin, newVcpuPinNum,
|
||||
vcpu) < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("failed to set cpuset.cpus in cgroup"
|
||||
" for vcpu %d"), vcpu);
|
||||
@ -5153,16 +5154,14 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
||||
virDomainVcpuPinDel(vm->def, vcpu);
|
||||
} else {
|
||||
if (vm->def->cputune.vcpupin)
|
||||
virDomainVcpuPinDefArrayFree(vm->def->cputune.vcpupin, vm->def->cputune.nvcpupin);
|
||||
virDomainVcpuPinDefArrayFree(vm->def->cputune.vcpupin,
|
||||
vm->def->cputune.nvcpupin);
|
||||
|
||||
vm->def->cputune.vcpupin = newVcpuPin;
|
||||
vm->def->cputune.nvcpupin = newVcpuPinNum;
|
||||
newVcpuPin = NULL;
|
||||
}
|
||||
|
||||
if (newVcpuPin)
|
||||
virDomainVcpuPinDefArrayFree(newVcpuPin, newVcpuPinNum);
|
||||
|
||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
||||
goto endjob;
|
||||
|
||||
@ -5211,6 +5210,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
||||
qemuDomainObjEndJob(driver, vm);
|
||||
|
||||
cleanup:
|
||||
if (newVcpuPin)
|
||||
virDomainVcpuPinDefArrayFree(newVcpuPin, newVcpuPinNum);
|
||||
if (cgroup_vcpu)
|
||||
virCgroupFree(&cgroup_vcpu);
|
||||
qemuDomObjEndAPI(&vm);
|
||||
|
Loading…
Reference in New Issue
Block a user