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:
parent
fcde3f1a05
commit
27884e3bd1
@ -4398,6 +4398,7 @@ vfs_kqfilter(struct vop_kqfilter_args *ap)
|
|||||||
if (vp->v_pollinfo == NULL)
|
if (vp->v_pollinfo == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
knl = &vp->v_pollinfo->vpi_selinfo.si_note;
|
knl = &vp->v_pollinfo->vpi_selinfo.si_note;
|
||||||
|
vhold(vp);
|
||||||
knlist_add(knl, kn, 0);
|
knlist_add(knl, kn, 0);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@ -4413,6 +4414,7 @@ filt_vfsdetach(struct knote *kn)
|
|||||||
|
|
||||||
KASSERT(vp->v_pollinfo != NULL, ("Missing v_pollinfo"));
|
KASSERT(vp->v_pollinfo != NULL, ("Missing v_pollinfo"));
|
||||||
knlist_remove(&vp->v_pollinfo->vpi_selinfo.si_note, kn, 0);
|
knlist_remove(&vp->v_pollinfo->vpi_selinfo.si_note, kn, 0);
|
||||||
|
vdrop(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
|
Loading…
Reference in New Issue
Block a user