svn commit: r349944 - head/usr.sbin/bhyve

Sean Chittenden seanc at FreeBSD.org
Fri Jul 12 18:13:59 UTC 2019


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;


More information about the svn-src-all mailing list