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
@ -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