]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fix NULL pointer access in qemuProcessInitCpuAffinity()
authorAndrea Bolognani <abologna@redhat.com>
Thu, 6 Jun 2019 13:38:29 +0000 (15:38 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 6 Jun 2019 14:50:11 +0000 (16:50 +0200)
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 <jferlan@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_process.c

index 42a62714116c312f5dd3959e0c600b3ef1f46eee..50a76aa0ed2971900cc81d263736cd43803210ca 100644 (file)
@@ -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)