usr.sbin/bhyve: don't leak a FD if the device is not a tty
Coverity CID: 1194193 Approved by: markj, jhb Differential Revision: https://reviews.freebsd.org/D20934
This commit is contained in:
parent
e7f77dfbc0
commit
e8c1d8680e
@ -678,9 +678,14 @@ uart_tty_backend(struct uart_softc *sc, const char *opts)
|
||||
int fd;
|
||||
|
||||
fd = open(opts, O_RDWR | O_NONBLOCK);
|
||||
if (fd < 0 || !isatty(fd))
|
||||
if (fd < 0)
|
||||
return (-1);
|
||||
|
||||
if (!isatty(fd)) {
|
||||
close(fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
sc->tty.rfd = sc->tty.wfd = fd;
|
||||
sc->tty.opened = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user