diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-11-09 20:54:25 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-11-09 20:54:25 +0000 |
commit | 6b8f490b777875eac382dcd10325ccfef5a77fe8 (patch) | |
tree | 43bbaf25be936ae882dd0916527462579b47ae29 /sys/kern/kern_descrip.c | |
parent | 07c0605ab8ee1d858a12347a7df2bf7417c35120 (diff) | |
download | FreeBSD-src-6b8f490b777875eac382dcd10325ccfef5a77fe8.zip FreeBSD-src-6b8f490b777875eac382dcd10325ccfef5a77fe8.tar.gz |
In closef(), remove the assumption that there is a thread associated
with the file descriptor. When a file descriptor is closed as a result
of garbage collecting a UNIX domain socket, the file descriptor will
not have any associated thread, so the logic to identify advisory locks
held by that thread is not appropriate. Check the thread for NULL to
avoid this scenario. Expand an existing comment to say a bit more about
this.
MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index eae5b99..c55da3c 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1880,9 +1880,13 @@ closef(struct file *fp, struct thread *td) * a flag in the unlock to free ONLY locks obeying POSIX * semantics, and not to free BSD-style file locks. * If the descriptor was in a message, POSIX-style locks - * aren't passed with the descriptor. + * aren't passed with the descripto, and the thread pointer + * will be NULL. Callers should be careful only to pass a + * NULL thread pointer when there really is no owning + * context that might have locks, or the locks will be + * leaked. */ - if (fp->f_type == DTYPE_VNODE) { + if (fp->f_type == DTYPE_VNODE && td != NULL) { int vfslocked; vp = fp->f_vnode; |