]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Don't free PCI device if adding it to activePciHostdevs fails
authorJiri Denemark <jdenemar@redhat.com>
Fri, 30 Nov 2012 15:52:03 +0000 (16:52 +0100)
committerCole Robinson <crobinso@redhat.com>
Sun, 9 Dec 2012 21:53:41 +0000 (16:53 -0500)
The device is still referenced from pcidevs and freeing it would leave
an invalid pointer there.
(cherry picked from commit ea1a9b5fddd1562abf31eb5c2502879bfd25903e)

src/qemu/qemu_hostdev.c

index 7375d26de12e4ba0eabec52804bce570f456bdd0..3cfaaf560469df46a6c196c874913fce5b4b1670 100644 (file)
@@ -491,10 +491,8 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
     /* Loop 5: Now mark all the devices as active */
     for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
         pciDevice *dev = pciDeviceListGet(pcidevs, i);
-        if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
-            pciFreeDevice(dev);
+        if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0)
             goto inactivedevs;
-        }
     }
 
     /* Loop 6: Now remove the devices from inactive list. */