[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu: Fix FD leak in qemudStartVMDaemon



On Wed, Mar 17, 2010 at 10:35:51PM +0100, Matthias Bolte wrote:
> The logfile FD is dup2'ed in __virExec in the child. The FD needs to
> be closed in the parent, otherwise it leaks.
> ---
>  src/qemu/qemu_driver.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index c8f3a15..fbb1275 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2963,6 +2963,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
>      if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
>          goto abort;
>  
> +    if (logfile != -1)
> +        close(logfile);
> +
>      return 0;
>  
>  cleanup:

  ACK, but we test

  if ((logfile = ...) < 0)
       goto cleanup;

so the logical counterpart would be 

  if (logfile >= 0)
      close(logfile);

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]