[libvirt] [PATCH RESEND] command: avoid fd leak on failure

Eric Blake eblake at redhat.com
Thu Oct 13 18:06:00 UTC 2011


On 10/13/2011 03:03 AM, Daniel Veillard wrote:
> On Wed, Oct 12, 2011 at 05:59:40PM -0600, Eric Blake wrote:
>> virCommandTransferFD promises that the fd is no longer owned by
>> the caller.  Normally, we want the fd to remain open until the
>> child runs, but in error situations, we must close it earlier.
>>
>> * src/util/command.c (virCommandTransferFD): Close fd now if we
>> can't track it to close later.
>> (virCommandKeepFD): Adjust helper to make this easier.
>> ---
>>
>> This leak can only happen on OOM or other extreme error conditions,
>> but ought to be plugged.  When I originally posted this:
>> https://www.redhat.com/archives/libvir-list/2011-July/msg00674.html
>> DV was worried that callers might abuse things and use fd
>> even after this function closed it; but I proved to myself in
>> writing a (non-working) v2 that all callers were already safe,
>> and that this v1 was indeed a smaller solution.
>
>    Okidoc then :-)
>

>    ACK,

Thanks; pushed.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list