Skip to content

Commit a84922c

Browse files
qemu: Fix NULL pointer access in qemuProcessInitCpuAffinity()
Commit 2f2254c attempted to fix a memory leak by ensuring cpumapToSet is always a freshly allocated bitmap, but regrettably introduced a NULL pointer access while doing so, because it called virBitmapCopy() without allocating the destination bitmap first. Solve the issue by using virBitmapNewCopy() instead. Reported-by: John Ferlan <[email protected]> Signed-off-by: Andrea Bolognani <[email protected]> Reviewed-by: Erik Skultety <[email protected]> Reviewed-by: John Ferlan <[email protected]>
1 parent 01628f4 commit a84922c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/qemu/qemu_process.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
24982498
if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0)
24992499
return -1;
25002500
} else if (vm->def->cputune.emulatorpin) {
2501-
if (virBitmapCopy(cpumapToSet, vm->def->cputune.emulatorpin) < 0)
2501+
if (!(cpumapToSet = virBitmapNewCopy(vm->def->cputune.emulatorpin)))
25022502
return -1;
25032503
} else {
25042504
if (qemuProcessGetAllCpuAffinity(&cpumapToSet) < 0)

0 commit comments

Comments
 (0)