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

Re: [libvirt] [PATCH] virsh: fix memory leak in virsh when starting a guest with invalid fd



On 02/20/2014 02:29 AM, Jincheng Miao wrote:
> When start a guest with --pass-fd, if the argument of --pass-fd is invalid,
> virsh will exit, but doesn't free the variable 'dom'.
> 

> +++ b/tools/virsh-domain.c
> @@ -3428,11 +3428,11 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
>      if (virDomainGetID(dom) != (unsigned int)-1) {
>          vshError(ctl, "%s", _("Domain is already active"));
>          virDomainFree(dom);
> -        return false;
> +        goto cleanup;
>      }

As is, this change ends up with a double-free calling virDomainFree(dom)
twice.  Delete the one here, and let the cleanup label handle it instead.

>  
>      if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0)
> -        return false;
> +        goto cleanup;

at which point this is also correct.  I'll push the amended patch shortly.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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