tty: fix a panic with INVARIANTS
watch'ing a tty triggers a refcount wraparound panic, take a reference
on fp after fget_cap_locked() to fix.
Reported by: Michael Jung <mikej_at_paymentallianceintl.com>
Reviewed by: hselasky, mjg
Fixes: f40dd6c803
("tty: switch ttyhook_register to use fget_cap_locked")
Differential Revision: https://reviews.freebsd.org/D34335
This commit is contained in:
parent
884ba43116
commit
0a2f498234
@ -2083,6 +2083,8 @@ ttyhook_register(struct tty **rtp, struct proc *p, int fd, struct ttyhook *th,
|
||||
FILEDESC_SLOCK(fdp);
|
||||
error = fget_cap_locked(fdp, fd, cap_rights_init_one(&rights, CAP_TTYHOOK),
|
||||
&fp, NULL);
|
||||
if (error == 0 && !fhold(fp))
|
||||
error = EBADF;
|
||||
FILEDESC_SUNLOCK(fdp);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user