[lxc-devel] [PATCH 1/3] Use correct return when clone fails

Serge Hallyn serge.hallyn at ubuntu.com
Mon Nov 9 23:35:19 UTC 2015


Quoting Christian Brauner (christian.brauner at mailbox.org):
> From: Christian Brauner <christianvanbrauner at gmail.com>
> 
> When the clone failed we tried to destroy the container. This will lead to a
> segfault. Instead simply return -1. Also move the call to free_mnts() after the
> put label to free the user specified mounts even when we just goto put.
> 
> Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/lxc_copy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxc_copy.c b/src/lxc/lxc_copy.c
> index ac1b051..1a2d007 100644
> --- a/src/lxc/lxc_copy.c
> +++ b/src/lxc/lxc_copy.c
> @@ -388,7 +388,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
>  	clone = c->clone(c, my_args->newname, my_args->newpath, flags,
>  			 my_args->bdevtype, NULL, my_args->fssize, args);
>  	if (!clone)
> -		goto err;
> +		return -1;
>  
>  	if (!my_args->keepdata)
>  		if (!clone->set_config_item(clone, "lxc.ephemeral", "1"))
> @@ -439,9 +439,9 @@ static int do_clone_ephemeral(struct lxc_container *c,
>  	return 0;
>  
>  err:
> -	free_mnts(mnts, num);
>  	clone->destroy(clone);
>  put:
> +	free_mnts(mnts, num);
>  	lxc_container_put(clone);
>  	return -1;
>  }
> -- 
> 2.6.2
> 


More information about the lxc-devel mailing list