From: Andrea Bolognani Date: Thu, 6 Jun 2019 13:38:29 +0000 (+0200) Subject: qemu: Fix NULL pointer access in qemuProcessInitCpuAffinity() X-Git-Tag: v5.5.0-rc1~331 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a84922c09e9e1a0ca4f8fb1e8b4b1c7b55bd79e9;p=thirdparty%2Flibvirt.git qemu: Fix NULL pointer access in qemuProcessInitCpuAffinity() Commit 2f2254c7f4e5 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 Signed-off-by: Andrea Bolognani Reviewed-by: Erik Skultety Reviewed-by: John Ferlan --- diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 42a6271411..50a76aa0ed 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2498,7 +2498,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm) if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0) return -1; } else if (vm->def->cputune.emulatorpin) { - if (virBitmapCopy(cpumapToSet, vm->def->cputune.emulatorpin) < 0) + if (!(cpumapToSet = virBitmapNewCopy(vm->def->cputune.emulatorpin))) return -1; } else { if (qemuProcessGetAllCpuAffinity(&cpumapToSet) < 0)