Skip to content
Browse files

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)
  • Loading branch information...
1 parent 56ada0c commit c58dbf73e0a6e0d54f57e8c3b51b2b554625defe @kostikbel kostikbel committed Sep 26, 2013
Showing with 2 additions and 0 deletions.
  1. +2 −0 sys/kern/vfs_subr.c
View
2 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*/

0 comments on commit c58dbf7

Please sign in to comment.
Something went wrong with that request. Please try again.