]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Use correct return when clone fails
authorChristian Brauner <christianvanbrauner@gmail.com>
Mon, 9 Nov 2015 20:47:27 +0000 (21:47 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 17 Nov 2015 16:35:44 +0000 (11:35 -0500)
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@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc_copy.c

index 2ce4c912738a02a1e93a8304e733f0e070bbf966..6336b537be463f6678b0171b2ee208c87fec09f8 100644 (file)
@@ -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;
 }