diff options
author | truckman <truckman@FreeBSD.org> | 2003-11-16 01:11:11 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2003-11-16 01:11:11 +0000 |
commit | 24b3a6d135ec98f318bf0eb08704b543b5371a3f (patch) | |
tree | 6d67dc256f5510d56d60c8c4f6550678f15a17af /sys/fs/fifofs | |
parent | 60cfaec287e48912137a3f53bc6d7b1294c3c453 (diff) | |
download | FreeBSD-src-24b3a6d135ec98f318bf0eb08704b543b5371a3f.zip FreeBSD-src-24b3a6d135ec98f318bf0eb08704b543b5371a3f.tar.gz |
Use "fip->fi_readers == 0 && fip->fi_writers == 0" as the condition for
disposing fifo resources in fifo_cleanup() instead using of
"vp->v_usecount == 1". There may be other references to the vnode, for
instance by nullfs, at the time fifo_open() or fifo_close() is called,
which could cause a resource leak.
Don't bother grabbing the vnode interlock in fifo_cleanup() since it no
longer accesses v_usecount.
Diffstat (limited to 'sys/fs/fifofs')
-rw-r--r-- | sys/fs/fifofs/fifo_vnops.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 36f8357..e7112d0 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -155,22 +155,19 @@ fifo_lookup(ap) /* * Dispose of fifo resources. - * Should be called with vnode locked */ static void fifo_cleanup(struct vnode *vp) { struct fifoinfo *fip = vp->v_fifoinfo; - VI_LOCK(vp); - if (vp->v_usecount == 1) { + ASSERT_VOP_LOCKED(vp, "fifo_cleanup"); + if (fip->fi_readers == 0 && fip->fi_writers == 0) { vp->v_fifoinfo = NULL; - VI_UNLOCK(vp); (void)soclose(fip->fi_readsock); (void)soclose(fip->fi_writesock); FREE(fip, M_VNODE); - } else - VI_UNLOCK(vp); + } } /* |