diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2004-03-02 04:42:53 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2004-03-02 04:42:53 +0000 |
commit | 1150c166ca7098458f6f565544bd7647c9388036 (patch) | |
tree | 902ddcd0628a6d42b4c1d030d4d480792b0fe2d7 /sys/miscfs | |
parent | fdd02ca007ad813e1ebc8ed7f27ca6207425181d (diff) |
prevent memory leak on revoke by freeing resources in a real reclaim
function.
also check fifoinfo is valid before deref.
ok millert@
Diffstat (limited to 'sys/miscfs')
-rw-r--r-- | sys/miscfs/fifofs/fifo.h | 6 | ||||
-rw-r--r-- | sys/miscfs/fifofs/fifo_vnops.c | 23 |
2 files changed, 25 insertions, 4 deletions
diff --git a/sys/miscfs/fifofs/fifo.h b/sys/miscfs/fifofs/fifo.h index 9fc76eb5a00..cdd59999b76 100644 --- a/sys/miscfs/fifofs/fifo.h +++ b/sys/miscfs/fifofs/fifo.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fifo.h,v 1.14 2003/09/23 16:51:13 millert Exp $ */ +/* $OpenBSD: fifo.h,v 1.15 2004/03/02 04:42:52 tedu Exp $ */ /* $NetBSD: fifo.h,v 1.10 1996/02/09 22:40:15 christos Exp $ */ /* @@ -64,8 +64,8 @@ int fifo_kqfilter(void *); #define fifo_readdir fifo_badop #define fifo_readlink fifo_badop #define fifo_abortop fifo_badop -int fifo_inactive(void *); -#define fifo_reclaim nullop +int fifo_inactive(void *); +int fifo_reclaim(void *); #define fifo_lock vop_generic_lock #define fifo_unlock vop_generic_unlock int fifo_bmap(void *); diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c index 74e9eb51a64..157f00fd8e9 100644 --- a/sys/miscfs/fifofs/fifo_vnops.c +++ b/sys/miscfs/fifofs/fifo_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fifo_vnops.c,v 1.18 2004/02/24 03:56:06 millert Exp $ */ +/* $OpenBSD: fifo_vnops.c,v 1.19 2004/03/02 04:42:52 tedu Exp $ */ /* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */ /* @@ -430,6 +430,9 @@ fifo_close(v) register struct fifoinfo *fip = vp->v_fifoinfo; int error1 = 0, error2 = 0; + if (fip == NULL) + return (0); + if (ap->a_fflag & FREAD) { if (--fip->fi_readers == 0) socantsendmore(fip->fi_writesock); @@ -447,6 +450,24 @@ fifo_close(v) return (error1 ? error1 : error2); } +int +fifo_reclaim(void *v) +{ + struct vop_reclaim_args *ap = v; + struct vnode *vp = ap->a_vp; + struct fifoinfo *fip = vp->v_fifoinfo; + + if (fip == NULL) + return (0); + + soclose(fip->fi_readsock); + soclose(fip->fi_writesock); + FREE(fip, M_VNODE); + vp->v_fifoinfo = NULL; + + return (0); +} + /* * Print out the contents of a fifo vnode. */ |