mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Make sure you don't have a file descriptor leak for the 'real'
underlying CAM device. This needs to be checked not only in the open routine, but the device->fd has to be initialized as well. PR: 28688 Submitted (partially) by: T. William Wells <bill@twwells.com> MFC after: 2 weeks
This commit is contained in:
parent
d79bee64d0
commit
3d09a65d42
1 changed files with 5 additions and 1 deletions
|
|
@ -554,7 +554,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
|
|||
char newpath[MAXPATHLEN+1];
|
||||
char *func_name = "cam_real_open_device";
|
||||
union ccb ccb;
|
||||
int fd, malloced_device = 0;
|
||||
int fd = -1, malloced_device = 0;
|
||||
|
||||
/*
|
||||
* See if the user wants us to malloc a device for him.
|
||||
|
|
@ -567,6 +567,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
|
|||
strerror(errno));
|
||||
return(NULL);
|
||||
}
|
||||
device->fd = -1;
|
||||
malloced_device = 1;
|
||||
}
|
||||
|
||||
|
|
@ -691,6 +692,9 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
|
|||
|
||||
crod_bailout:
|
||||
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
|
||||
if (malloced_device)
|
||||
free(device);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue