From: Christian Brauner Date: Wed, 27 Jan 2021 19:37:42 +0000 (+0100) Subject: attach: use __do_close for labelfd X-Git-Tag: lxc-5.0.0~314^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad001fb6d76361625fda40a1ae80b402734ef394;p=thirdparty%2Flxc.git attach: use __do_close for labelfd Cc: stable-4.0 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index a59b20fe5..6ade5969c 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -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); }