Source-Changes-HG archive

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

[src/trunk]: src/sys/kern assert that vmem_alloc() with VM_SLEEP does not fail.



details:   https://anonhg.NetBSD.org/src/rev/67fa8a6c8734
branches:  trunk
changeset: 354011:67fa8a6c8734
user:      chs <chs%NetBSD.org@localhost>
date:      Wed May 31 23:53:30 2017 +0000

description:
assert that vmem_alloc() with VM_SLEEP does not fail.

diffstat:

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

diffs (45 lines):

diff -r f045db832921 -r 67fa8a6c8734 sys/kern/subr_vmem.c
--- a/sys/kern/subr_vmem.c      Wed May 31 22:02:06 2017 +0000
+++ b/sys/kern/subr_vmem.c      Wed May 31 23:53:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_vmem.c,v 1.95 2016/07/07 06:55:43 msaitoh Exp $   */
+/*     $NetBSD: subr_vmem.c,v 1.96 2017/05/31 23:53:30 chs Exp $       */
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.95 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.96 2017/05/31 23:53:30 chs Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -1037,6 +1037,7 @@
 vmem_alloc(vmem_t *vm, vmem_size_t size, vm_flag_t flags, vmem_addr_t *addrp)
 {
        const vm_flag_t strat __diagused = flags & VM_FITMASK;
+       int error;
 
        KASSERT((flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
        KASSERT((~flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
@@ -1056,12 +1057,16 @@
                p = pool_cache_get(qc->qc_cache, vmf_to_prf(flags));
                if (addrp != NULL)
                        *addrp = (vmem_addr_t)p;
-               return (p == NULL) ? ENOMEM : 0;
+               error = (p == NULL) ? ENOMEM : 0;
+               goto out;
        }
 #endif /* defined(QCACHE) */
 
-       return vmem_xalloc(vm, size, 0, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
+       error = vmem_xalloc(vm, size, 0, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
            flags, addrp);
+out:
+       KASSERT(error == 0 || (flags & VM_SLEEP) == 0);
+       return error;
 }
 
 int



Home | Main Index | Thread Index | Old Index