Source-Changes-HG archive

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

[src/trunk]: src/sys/kern kmem(9): Make kmem_alloc and kmem_free agree about ...



details:   https://anonhg.NetBSD.org/src/rev/98cce42b129e
branches:  trunk
changeset: 363439:98cce42b129e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 12 16:54:17 2022 +0000

description:
kmem(9): Make kmem_alloc and kmem_free agree about rejecting zero.

Let's do both as KASSERT, unless there's a good reason to make them
both do an unconditional if/panic even in release builds.

diffstat:

 sys/kern/subr_kmem.c |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (29 lines):

diff -r 4f7cc10ea2cb -r 98cce42b129e sys/kern/subr_kmem.c
--- a/sys/kern/subr_kmem.c      Sat Mar 12 16:51:10 2022 +0000
+++ b/sys/kern/subr_kmem.c      Sat Mar 12 16:54:17 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_kmem.c,v 1.82 2021/02/06 13:54:48 joerg Exp $     */
+/*     $NetBSD: subr_kmem.c,v 1.83 2022/03/12 16:54:17 riastradh Exp $ */
 
 /*
  * Copyright (c) 2009-2020 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.82 2021/02/06 13:54:48 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.83 2022/03/12 16:54:17 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kmem.h"
@@ -258,9 +258,7 @@
        pool_cache_t pc;
 
        KASSERT(p != NULL);
-       if (__predict_false(requested_size == 0)) {
-               panic("%s: zero size with pointer %p", __func__, p);
-       }
+       KASSERT(requested_size > 0);
 
        kasan_add_redzone(&requested_size);
        size = kmem_roundup_size(requested_size);



Home | Main Index | Thread Index | Old Index