pci: eliminate leak in OOM condition

The "fix" I pushed a few commits ago would still leak a virPCIDevice
in case of an OOM error. Although it's inconsequential in practice,
this patch satisfies my OCD.
This commit is contained in:
Laine Stump 2013-06-24 21:30:55 -04:00
parent 0e89a543be
commit 2a2739a866

View File

@ -1268,11 +1268,9 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
/* Add *a copy of* the dev into list inactiveDevs, if
* it's not already there.
*/
if (inactiveDevs && !virPCIDeviceListFind(inactiveDevs, dev)) {
virPCIDevicePtr copy = virPCIDeviceCopy(dev);
if ((!copy) || virPCIDeviceListAdd(inactiveDevs, copy) < 0)
return -1;
if (inactiveDevs && !virPCIDeviceListFind(inactiveDevs, dev) &&
virPCIDeviceListAddCopy(inactiveDevs, dev) < 0) {
return -1;
}
return 0;