tty: switch ttyhook_register to use fget_cap_locked
It is still wrong-ish as fget* funcs don't expect to operate on abitrary file descriptor tables, but this at least moves it out of the way of an upcoming change while being bug-compatible.
This commit is contained in:
parent
93288e2445
commit
f40dd6c803
@ -2074,9 +2074,16 @@ ttyhook_register(struct tty **rtp, struct proc *p, int fd, struct ttyhook *th,
|
||||
int error, ref;
|
||||
|
||||
/* Validate the file descriptor. */
|
||||
/*
|
||||
* XXX this code inspects a file descriptor from a different process,
|
||||
* but there is no dedicated routine to do it in fd code, making the
|
||||
* ordeal highly questionable.
|
||||
*/
|
||||
fdp = p->p_fd;
|
||||
error = fget_unlocked(fdp, fd, cap_rights_init_one(&rights, CAP_TTYHOOK),
|
||||
&fp);
|
||||
FILEDESC_SLOCK(fdp);
|
||||
error = fget_cap_locked(fdp, fd, cap_rights_init_one(&rights, CAP_TTYHOOK),
|
||||
&fp, NULL);
|
||||
FILEDESC_SUNLOCK(fdp);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (fp->f_ops == &badfileops) {
|
||||
|
Loading…
Reference in New Issue
Block a user