qemu: Don't free PCI device if adding it to activePciHostdevs fails

The device is still referenced from pcidevs and freeing it would leave
an invalid pointer there.
This commit is contained in:
Jiri Denemark 2012-11-30 16:52:03 +01:00
parent 935550c6d3
commit ea1a9b5fdd

View 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. */