]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: always close pipe in run_userns_fn()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 29 Jul 2018 21:03:32 +0000 (23:03 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 15:02:09 +0000 (16:02 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 6e53aa6adcc23cb329116a47976ea4dc685e44bd..5d8090703d77c94f79c01be8241db4eafe8ce0ae 100644 (file)
@@ -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);
 }