Skip to content

Commit

Permalink
coverity: #1425879
Browse files Browse the repository at this point in the history
do not double close file descriptor

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Dec 17, 2017
1 parent dac3dca commit c192dc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lxc/console.c
Expand Up @@ -546,14 +546,20 @@ void lxc_console_delete(struct lxc_console *console)
free(console->tios);
console->tios = NULL;

close(console->peer);
close(console->master);
close(console->slave);
if (console->log_fd >= 0)
close(console->log_fd);
if (console->peer >= 0)
close(console->peer);
console->peer = -1;

if (console->master >= 0)
close(console->master);
console->master = -1;

if (console->slave >= 0)
close(console->slave);
console->slave = -1;

if (console->log_fd >= 0)
close(console->log_fd);
console->log_fd = -1;
}

Expand Down
1 change: 1 addition & 0 deletions src/lxc/tools/lxc_attach.c
Expand Up @@ -348,6 +348,7 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
if (c->attach(c, get_pty_on_host_callback, wrap, wrap->options, pid) < 0)
goto err1;
close(conf->console.slave); /* Close slave side. */
conf->console.slave = -1;

ret = lxc_mainloop_open(&descr);
if (ret) {
Expand Down

0 comments on commit c192dc0

Please sign in to comment.