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
b5a05fcd18
commit
489b0cc9ad
@ -664,21 +664,19 @@ altcons_open(char *path)
|
|||||||
static int
|
static int
|
||||||
disk_open(char *path)
|
disk_open(char *path)
|
||||||
{
|
{
|
||||||
int err, fd;
|
int fd;
|
||||||
|
|
||||||
if (ndisks >= NDISKS)
|
if (ndisks >= NDISKS)
|
||||||
return (ERANGE);
|
return (ERANGE);
|
||||||
|
|
||||||
err = 0;
|
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return (errno);
|
||||||
|
|
||||||
if (fd > 0) {
|
disk_fd[ndisks] = fd;
|
||||||
disk_fd[ndisks] = fd;
|
ndisks++;
|
||||||
ndisks++;
|
|
||||||
} else
|
|
||||||
err = errno;
|
|
||||||
|
|
||||||
return (err);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user