nspawn: fix fd leak on failure path

This commit is contained in:
Lennart Poettering 2020-09-16 22:16:10 +02:00
parent 554c4beb47
commit 2fef50cd9e
1 changed files with 2 additions and 1 deletions

View File

@ -2275,7 +2275,7 @@ static int setup_pts(const char *dest) {
}
static int setup_stdio_as_dev_console(void) {
int terminal;
_cleanup_close_ int terminal = -1;
int r;
terminal = open_terminal("/dev/console", O_RDWR);
@ -2290,6 +2290,7 @@ static int setup_stdio_as_dev_console(void) {
/* invalidates 'terminal' on success and failure */
r = rearrange_stdio(terminal, terminal, terminal);
TAKE_FD(terminal);
if (r < 0)
return log_error_errno(r, "Failed to move console to stdin/stdout/stderr: %m");