diff options
author | jhb <jhb@FreeBSD.org> | 2011-12-09 17:49:34 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-12-09 17:49:34 +0000 |
commit | b00203c514ba652db03e1509ae47fbdc75afd629 (patch) | |
tree | 0b915424b33c81844740ad3e16df9bf3e1b074aa /sys/fs/devfs | |
parent | 109ecfbeb1319e392b9ab944c5dd245ffff25bd2 (diff) | |
download | FreeBSD-src-b00203c514ba652db03e1509ae47fbdc75afd629.zip FreeBSD-src-b00203c514ba652db03e1509ae47fbdc75afd629.tar.gz |
Explicitly use curthread while manipulating td_fpop during last close
of a devfs file descriptor in devfs_close_f(). The passed in td argument
may be NULL if the close was invoked by garbage collection of open
file descriptors in pending control messages in the socket buffer of a
UNIX domain socket after it was closed.
PR: kern/151758
Submitted by: Andrey Shidakov andrey shidakov ru
Submitted by: Ruben van Staveren ruben verweg com
Reviewed by: kib
MFC after: 2 weeks
Diffstat (limited to 'sys/fs/devfs')
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 22908b9..408c981 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -602,10 +602,14 @@ devfs_close_f(struct file *fp, struct thread *td) int error; struct file *fpop; - fpop = td->td_fpop; - td->td_fpop = fp; + /* + * NB: td may be NULL if this descriptor is closed due to + * garbage collection from a closed UNIX domain socket. + */ + fpop = curthread->td_fpop; + curthread->td_fpop = fp; error = vnops.fo_close(fp, td); - td->td_fpop = fpop; + curthread->td_fpop = fpop; /* * The f_cdevpriv cannot be assigned non-NULL value while we |