]> 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)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 5 Dec 2012 12:45:34 +0000 (13:45 +0100)
The device is still referenced from pcidevs and freeing it would leave
an invalid pointer there.

src/qemu/qemu_hostdev.c

index ab0f173219ec7b166fc710ac4601fd0180e03cfa..b79319e389abb57d215be8d9c591b64489896439 100644 (file)
@@ -491,10 +491,8 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr 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. */