Author: seanc (ports committer)
Date: Fri Jul 12 18:13:58 2019
New Revision: 349944
URL: https://svnweb.freebsd.org/changeset/base/349944

Log:
  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

Modified:
  head/usr.sbin/bhyve/uart_emul.c

Modified: head/usr.sbin/bhyve/uart_emul.c
==============================================================================
--- head/usr.sbin/bhyve/uart_emul.c     Fri Jul 12 15:24:25 2019        
(r349943)
+++ head/usr.sbin/bhyve/uart_emul.c     Fri Jul 12 18:13:58 2019        
(r349944)
@@ -678,8 +678,13 @@ uart_tty_backend(struct uart_softc *sc, const char *op
        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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to