Date: Fri, 12 Jul 2019 18:38:19 +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: r349949 - head/usr.sbin/bhyveload Message-ID: <201907121838.x6CIcJ3K039479@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907121838.x6CIcJ3K039479>