summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-09-26 13:14:51 +0000
committerkib <kib@FreeBSD.org>2013-09-26 13:14:51 +0000
commitc58dbf73e0a6e0d54f57e8c3b51b2b554625defe (patch)
treecd389ed5a22579c650548cac956ffa2d52d99c37 /sys/kern/vfs_subr.c
parent56ada0cb09eee44cb374667ecbeed22977d7c4cf (diff)
downloadFreeBSD-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)
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r--sys/kern/vfs_subr.c2
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*/
OpenPOWER on IntegriCloud