]> git.proxmox.com Git - mirror_lxc.git/commitdiff
conf: cleanup macros lxc_chroot
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 19 Feb 2019 22:43:27 +0000 (23:43 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 19 Feb 2019 22:43:27 +0000 (23:43 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 7bea4646818fae56cee914033e6b15757d18a168..06f212fcd9f58f29b65b44aa064dc89c78b5b775 100644 (file)
@@ -1345,10 +1345,10 @@ static int lxc_mount_rootfs(struct lxc_conf *conf)
 
 int lxc_chroot(const struct lxc_rootfs *rootfs)
 {
+       __do_free char *nroot = NULL;
        int i, ret;
        char *p, *p2;
        char buf[LXC_LINELEN];
-       char *nroot;
        FILE *f;
        char *root = rootfs->mount;
 
@@ -1359,10 +1359,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs)
        }
 
        ret = chdir("/");
-       if (ret < 0) {
-               free(nroot);
+       if (ret < 0)
                return -1;
-       }
 
        /* We could use here MS_MOVE, but in userns this mount is locked and
         * can't be moved.
@@ -1370,10 +1368,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs)
        ret = mount(nroot, "/", NULL, MS_REC | MS_BIND, NULL);
        if (ret < 0) {
                SYSERROR("Failed to mount \"%s\" onto \"/\" as MS_REC | MS_BIND", nroot);
-               free(nroot);
                return -1;
        }
-       free(nroot);
 
        ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL);
        if (ret < 0) {