Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jul 2019 18:13:58 +0000 (UTC)
From:      Sean Chittenden <seanc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349944 - head/usr.sbin/bhyve
Message-ID:  <201907121813.x6CIDwFY028710@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907121813.x6CIDwFY028710>