On 06/24/2013 10:57 AM, Daniel P. Berrange wrote:
On Mon, Jun 24, 2013 at 05:54:54AM -0400, Laine Stump wrote:
> virPCIDeviceDetach would previously sometimes consume the input device
> object (to put it on the inactive list) and sometimes not. Avoiding
> memory leaks required checking beforehand to see if the device was
> already on the list, and freeing the device object in the caller only
> if there wasn't already an identical object on the inactive list.
>
> This patch makes it consistent - virPCIDeviceDetach will *never*
> consume the input virPCIDevice object; if it needs to put one on the
> inactive list, it will create a copy and put *that* on the list. This
> way the caller knows that it is always their responsibility to free
> the device object they created.
> ---
> src/qemu/qemu_driver.c | 8 +++-----
> src/util/virpci.c | 26 ++++++++++++++++++++++++--
> 2 files changed, 27 insertions(+), 7 deletions(-)
ACK much safer semantics.
I'm frankly surprised we don't have more crashes in this code.
I've pushed this now.