Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/filemon filemon_open: remove unnecessary check (whic...



details:   https://anonhg.NetBSD.org/src/rev/cc2c282ef82e
branches:  trunk
changeset: 764948:cc2c282ef82e
user:      rmind <rmind%NetBSD.org@localhost>
date:      Fri May 13 22:31:08 2011 +0000

description:
filemon_open: remove unnecessary check (which has a leak in error path).

diffstat:

 sys/dev/filemon/filemon.c |  10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diffs (35 lines):

diff -r 80ca45d4b2bd -r cc2c282ef82e sys/dev/filemon/filemon.c
--- a/sys/dev/filemon/filemon.c Fri May 13 22:28:40 2011 +0000
+++ b/sys/dev/filemon/filemon.c Fri May 13 22:31:08 2011 +0000
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.1 2010/09/09 00:10:16 sjg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.2 2011/05/13 22:31:08 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -195,20 +195,16 @@
                return error;
 
        filemon = kmem_alloc(sizeof(struct filemon), KM_SLEEP);
-       if (!filemon)
-               return ENOMEM;
-
        rw_init(&filemon->fm_mtx);
        filemon->fm_fd = -1;
        filemon->fm_fp = NULL;
        filemon->fm_pid = curproc->p_pid;
 
        rw_enter(&filemon_mtx, RW_WRITER);
+       TAILQ_INSERT_TAIL(&filemons_inuse, filemon, fm_link);
        n_open++;
+       rw_exit(&filemon_mtx);
 
-       TAILQ_INSERT_TAIL(&filemons_inuse, filemon, fm_link);
-
-       rw_exit(&filemon_mtx);
        return fd_clone(fp, fd, oflags, &filemon_fileops, filemon);
 }
 



Home | Main Index | Thread Index | Old Index