From: Christian Brauner Date: Sun, 29 Jul 2018 21:03:32 +0000 (+0200) Subject: conf: always close pipe in run_userns_fn() X-Git-Tag: lxc-2.0.10~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a12b86c8ed5b97244563b49078cd3d850466a56;p=thirdparty%2Flxc.git conf: always close pipe in run_userns_fn() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 6e53aa6ad..5d8090703 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -3763,8 +3763,9 @@ struct userns_fn_data { static int run_userns_fn(void *data) { - struct userns_fn_data *d = data; + int ret; char c; + struct userns_fn_data *d = data; /* Close write end of the pipe. */ close(d->p[1]); @@ -3772,14 +3773,15 @@ static int run_userns_fn(void *data) /* Wait for parent to finish establishing a new mapping in the user * namespace we are executing in. */ - if (lxc_read_nointr(d->p[0], &c, 1) != 1) - return -1; - + ret = lxc_read_nointr(d->p[0], &c, 1); /* Close read end of the pipe. */ close(d->p[0]); + if (ret != 1) + return -1; if (d->fn_name) - TRACE("calling function \"%s\"", d->fn_name); + TRACE("Calling function \"%s\"", d->fn_name); + /* Call function to run. */ return d->fn(d->arg); }