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)
This commit is contained in:
Konstantin Belousov 2013-09-26 13:14:51 +00:00
parent fcde3f1a05
commit 27884e3bd1

View File

@ -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*/