fd: fix up fgetvp_rights after r306184

fget_cap_locked returns a referenced file, but the fgetvp_rights does
not need it. Instead, due to the filedesc lock being held, it can
ref the vnode after the file was looked up.

Fix up fget_cap_locked to be consistent with other _locked helpers and not
ref the file.

This plugs a leak introduced in r306184.

Pointy hat to: mjg, oshogbo
This commit is contained in:
Mateusz Guzik 2016-09-23 06:51:46 +00:00
parent 1d2541fd1a
commit deffc4a026
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306226

View File

@ -2469,7 +2469,6 @@ fget_cap_locked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
if (havecapsp != NULL)
filecaps_copy(&fde->fde_caps, havecapsp, true);
fhold(fde->fde_file);
*fpp = fde->fde_file;
error = 0;
@ -2511,6 +2510,8 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
get_locked:
FILEDESC_SLOCK(fdp);
error = fget_cap_locked(fdp, fd, needrightsp, fpp, havecapsp);
if (error == 0)
fhold(*fpp);
FILEDESC_SUNLOCK(fdp);
return (error);