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

Log:
  usr.sbin/bhyveload: don't leak an fd if a device can't be opened
  
  Coverity CID: 1194167
  Approved by:  markj, jhb
  Differential Revision:        https://reviews.freebsd.org/D20935

Modified:
  head/usr.sbin/bhyveload/bhyveload.c

Modified: head/usr.sbin/bhyveload/bhyveload.c
==============================================================================
--- head/usr.sbin/bhyveload/bhyveload.c Fri Jul 12 18:37:56 2019        
(r349948)
+++ head/usr.sbin/bhyveload/bhyveload.c Fri Jul 12 18:38:18 2019        
(r349949)
@@ -664,21 +664,19 @@ altcons_open(char *path)
 static int
 disk_open(char *path)
 {
-       int err, fd;
+       int fd;
 
        if (ndisks >= NDISKS)
                return (ERANGE);
 
-       err = 0;
        fd = open(path, O_RDONLY);
+       if (fd < 0)
+               return (errno);
 
-       if (fd > 0) {
-               disk_fd[ndisks] = fd;
-               ndisks++;
-       } else 
-               err = errno;
+       disk_fd[ndisks] = fd;
+       ndisks++;
 
-       return (err);
+       return (0);
 }
 
 static void
_______________________________________________
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