From: Christian Brauner Date: Tue, 19 Feb 2019 22:43:27 +0000 (+0100) Subject: conf: cleanup macros lxc_chroot X-Git-Tag: lxc-3.2.0~132^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8d8876481736861bca42c9a6ec9391684809caf;p=thirdparty%2Flxc.git conf: cleanup macros lxc_chroot Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 7bea46468..06f212fcd 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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) {