conf: cleanup macros lxc_chroot

parent 8db92302
...@@ -1345,10 +1345,10 @@ static int lxc_mount_rootfs(struct lxc_conf *conf) ...@@ -1345,10 +1345,10 @@ static int lxc_mount_rootfs(struct lxc_conf *conf)
int lxc_chroot(const struct lxc_rootfs *rootfs) int lxc_chroot(const struct lxc_rootfs *rootfs)
{ {
__do_free char *nroot = NULL;
int i, ret; int i, ret;
char *p, *p2; char *p, *p2;
char buf[LXC_LINELEN]; char buf[LXC_LINELEN];
char *nroot;
FILE *f; FILE *f;
char *root = rootfs->mount; char *root = rootfs->mount;
...@@ -1359,10 +1359,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs) ...@@ -1359,10 +1359,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs)
} }
ret = chdir("/"); ret = chdir("/");
if (ret < 0) { if (ret < 0)
free(nroot);
return -1; return -1;
}
/* We could use here MS_MOVE, but in userns this mount is locked and /* We could use here MS_MOVE, but in userns this mount is locked and
* can't be moved. * can't be moved.
...@@ -1370,10 +1368,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs) ...@@ -1370,10 +1368,8 @@ int lxc_chroot(const struct lxc_rootfs *rootfs)
ret = mount(nroot, "/", NULL, MS_REC | MS_BIND, NULL); ret = mount(nroot, "/", NULL, MS_REC | MS_BIND, NULL);
if (ret < 0) { if (ret < 0) {
SYSERROR("Failed to mount \"%s\" onto \"/\" as MS_REC | MS_BIND", nroot); SYSERROR("Failed to mount \"%s\" onto \"/\" as MS_REC | MS_BIND", nroot);
free(nroot);
return -1; return -1;
} }
free(nroot);
ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL); ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment