mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-26 11:47:31 +00:00
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
This commit is contained in:
parent
422a8a4d3a
commit
a0bc451f0b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349949
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user