From: Jiri Denemark Date: Fri, 30 Nov 2012 15:52:03 +0000 (+0100) Subject: qemu: Don't free PCI device if adding it to activePciHostdevs fails X-Git-Tag: v1.0.1-rc1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea1a9b5fddd1562abf31eb5c2502879bfd25903e;p=thirdparty%2Flibvirt.git 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. --- diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index ab0f173219..b79319e389 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -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. */