mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 09:02:44 +00:00
Fix a file descriptor leak in cam_lookup_pass() when the ioctl to find
the passthru device fails. Approved by: scottl MFC after: 1 day
This commit is contained in:
parent
1b355c2dc7
commit
8bc181f506
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=158170
@ -465,7 +465,7 @@ static struct cam_device *
|
||||
cam_lookup_pass(const char *dev_name, int unit, int flags,
|
||||
const char *given_path, struct cam_device *device)
|
||||
{
|
||||
int fd;
|
||||
int fd, rc;
|
||||
union ccb ccb;
|
||||
char dev_path[256];
|
||||
char *func_name = "cam_lookup_pass";
|
||||
@ -494,7 +494,10 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
|
||||
* the device name is null, if the device doesn't exist, or if the
|
||||
* passthrough driver isn't in the kernel.
|
||||
*/
|
||||
if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) {
|
||||
rc = ioctl(fd, CAMGETPASSTHRU, &ccb);
|
||||
close(fd);
|
||||
|
||||
if (rc == -1) {
|
||||
char tmpstr[256];
|
||||
|
||||
/*
|
||||
@ -517,8 +520,6 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
/*
|
||||
* If the ioctl returned the right status, but we got an error back
|
||||
* in the ccb, that means that the kernel found the device the user
|
||||
|
Loading…
Reference in New Issue
Block a user