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

Re: [libvirt] [PATCH]LXC: free dst before lxcDomainAttachDeviceDiskLive return



On Thu, Sep 26, 2013 at 02:01:52PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao cn fujitsu com>
> 
> free dst before lxcDomainAttachDeviceDiskLive return
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao cn fujitsu com>
> ---
>  src/lxc/lxc_driver.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 9c58f67..7906ad1 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -3053,6 +3053,7 @@ cleanup:
>      virDomainAuditDisk(vm, NULL, def->src, "attach", ret == 0);
>      if (dst && created && ret < 0)
>          unlink(dst);
> +    VIR_FREE(dst);
>      return ret;
>  }

  Hum, it is a bit complex as the allocated dst is saved in
the definition a few lines earlier:

    /* Labelling normally operates on src, but we need
     * to actally label the dst here, so hack the config */
    def->src = dst;

and then in cleanup it's overriden again with the value saved at the
start of the function:

cleanup:
    def->src = tmpsrc;
    virDomainAuditDisk(vm, NULL, def->src, "attach", ret == 0);

the leak is real and that free certainly need to be added but maybe
there is a bit of cleanup needed rather than just adding the VIR_FREE()

 I will let someone with more knowledge of that code part decide :-)

Daniel


-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/


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