mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
pci: eliminate memory leak in virPCIDeviceReattach
virPCIDeviceReattach was making the assumption that the dev object given to it was one and the same with the dev object on the inactiveDevs list. If that had been the case, it would not need to free the dev object it removed from the inactive list, because the caller of virPCIDeviceReattach always frees the dev object that it passes in. Since the dev object passed in is *never* the same object that's on the list (it is a different object with the same name and attributes, created just for the purpose of searching for the actual object), simply doing a "ListSteal" to remove the object from the list results in one leaked object; we need to actually free the object after removing it from the list.
This commit is contained in:
parent
50a8d85035
commit
f962e8b603
@ -1266,7 +1266,7 @@ virPCIDeviceReattach(virPCIDevicePtr dev,
|
||||
|
||||
/* Steal the dev from list inactiveDevs */
|
||||
if (inactiveDevs)
|
||||
virPCIDeviceListSteal(inactiveDevs, dev);
|
||||
virPCIDeviceListDel(inactiveDevs, dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user