diff options
author | kib <kib@FreeBSD.org> | 2013-09-26 13:14:51 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-09-26 13:14:51 +0000 |
commit | c58dbf73e0a6e0d54f57e8c3b51b2b554625defe (patch) | |
tree | cd389ed5a22579c650548cac956ffa2d52d99c37 | |
parent | 56ada0cb09eee44cb374667ecbeed22977d7c4cf (diff) | |
download | FreeBSD-src-c58dbf73e0a6e0d54f57e8c3b51b2b554625defe.zip FreeBSD-src-c58dbf73e0a6e0d54f57e8c3b51b2b554625defe.tar.gz |
Acquire a hold reference on the vnode when a knote is instantiated.
Otherwise, knote keeps a pointer to a vnode which could become invalid
any time.
Reported by: many
Tested by: Patrick Lamaiziere <patfbsd@davenulle.org>
Discussed with: jmg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Approved by: re (marius)
-rw-r--r-- | sys/kern/vfs_subr.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 3cbc95f..23343f1 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4398,6 +4398,7 @@ vfs_kqfilter(struct vop_kqfilter_args *ap) if (vp->v_pollinfo == NULL) return (ENOMEM); knl = &vp->v_pollinfo->vpi_selinfo.si_note; + vhold(vp); knlist_add(knl, kn, 0); return (0); @@ -4413,6 +4414,7 @@ filt_vfsdetach(struct knote *kn) KASSERT(vp->v_pollinfo != NULL, ("Missing v_pollinfo")); knlist_remove(&vp->v_pollinfo->vpi_selinfo.si_note, kn, 0); + vdrop(vp); } /*ARGSUSED*/ |