attach: use __do_close for labelfd

Cc: stable-4.0 Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 4f3b6a85
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment