Source-Changes-HG archive

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

[src/trunk]: src/sys/kern in fd_allocfile(), free the fd if we fail to alloca...



details:   https://anonhg.NetBSD.org/src/rev/eeec4d4d73b7
branches:  trunk
changeset: 769885:eeec4d4d73b7
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Sep 25 13:40:37 2011 +0000

description:
in fd_allocfile(), free the fd if we fail to allocate a file.

diffstat:

 sys/kern/kern_descrip.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 9266574aa368 -r eeec4d4d73b7 sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c   Sun Sep 25 13:40:07 2011 +0000
+++ b/sys/kern/kern_descrip.c   Sun Sep 25 13:40:37 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_descrip.c,v 1.216 2011/07/15 14:50:19 christos Exp $      */
+/*     $NetBSD: kern_descrip.c,v 1.217 2011/09/25 13:40:37 chs Exp $   */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.216 2011/07/15 14:50:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.217 2011/09/25 13:40:37 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -291,7 +291,7 @@
        KASSERT(ff->ff_file == NULL);
        KASSERT(!ff->ff_allocated);
 
-       ff->ff_allocated = 1;
+       ff->ff_allocated = true;
        fdp->fd_lomap[off] |= 1 << (fd & NDENTRYMASK);
        if (__predict_false(fdp->fd_lomap[off] == ~0)) {
                KASSERT((fdp->fd_himap[off >> NDENTRYSHIFT] &
@@ -337,7 +337,7 @@
        }
        KASSERT((fdp->fd_lomap[off] & (1 << (fd & NDENTRYMASK))) != 0);
        fdp->fd_lomap[off] &= ~(1 << (fd & NDENTRYMASK));
-       ff->ff_allocated = 0;
+       ff->ff_allocated = false;
 
        KASSERT(fd <= fdp->fd_lastfile);
        if (fd == fdp->fd_lastfile) {
@@ -1083,6 +1083,7 @@
 
        fp = pool_cache_get(file_cache, PR_WAITOK);
        if (fp == NULL) {
+               fd_abort(p, NULL, *resultfd);
                return ENFILE;
        }
        KASSERT(fp->f_count == 0);



Home | Main Index | Thread Index | Old Index