]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: use __do_close for labelfd
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 27 Jan 2021 19:37:42 +0000 (20:37 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 27 Jan 2021 19:52:43 +0000 (20:52 +0100)
Cc: stable-4.0
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index a59b20fe57c7a8a0b5cf8acc813e889f60323302..6ade5969cb39bb57c9f8b6d72a13f5f89ea765f6 100644 (file)
@@ -1344,7 +1344,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
        /* Open LSM fd and send it to child. */
        if ((options->namespaces & CLONE_NEWNS) &&
            (options->attach_flags & LXC_ATTACH_LSM) && init_ctx->lsm_label) {
-               int labelfd;
+               __do_close int labelfd = -EBADF;
                bool on_exec;
 
                ret = -1;
@@ -1361,12 +1361,9 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
                if (ret <= 0) {
                        if (ret < 0)
                                SYSERROR("Failed to send lsm label fd");
-
-                       close(labelfd);
                        goto close_mainloop;
                }
 
-               close(labelfd);
                TRACE("Sent LSM label file descriptor %d to child", labelfd);
        }