Source-Changes-HG archive

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

[src/trunk]: src/external/cddl/osnet/sys/kern kmem_cache_create()'s "name" pa...



details:   https://anonhg.NetBSD.org/src/rev/2bac128db72d
branches:  trunk
changeset: 956940:2bac128db72d
user:      chs <chs%NetBSD.org@localhost>
date:      Wed Nov 11 03:31:04 2020 +0000

description:
kmem_cache_create()'s "name" parameter can be on the stack,
so make a copy of it rather than keeping a pointer to it.

diffstat:

 external/cddl/osnet/sys/kern/kmem.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 2491dc4f47c6 -r 2bac128db72d external/cddl/osnet/sys/kern/kmem.c
--- a/external/cddl/osnet/sys/kern/kmem.c       Tue Nov 10 23:32:33 2020 +0000
+++ b/external/cddl/osnet/sys/kern/kmem.c       Wed Nov 11 03:31:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kmem.c,v 1.2 2019/05/23 08:32:30 hannken Exp $ */
+/*     $NetBSD: kmem.c,v 1.3 2020/11/11 03:31:04 chs Exp $     */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,6 +30,7 @@
 
 struct kmem_cache {
        pool_cache_t km_pool;
+       char km_name[32];
        void *km_private;
        int (*km_constructor)(void *, void *, int);
        void (*km_destructor)(void *, void *);
@@ -78,11 +79,12 @@
        KASSERT(vmp == NULL);
 
        km = kmem_zalloc(sizeof(*km), KM_SLEEP);
+       strlcpy(km->km_name, name, sizeof(km->km_name));
        km->km_private = private;
        km->km_constructor = constructor;
        km->km_destructor = destructor;
        km->km_reclaim = reclaim;
-       km->km_pool = pool_cache_init(bufsize, align, 0, 0, name, NULL,
+       km->km_pool = pool_cache_init(bufsize, align, 0, 0, km->km_name, NULL,
            IPL_NONE, solaris_constructor, solaris_destructor, km);
        if (km->km_pool == NULL) {
                kmem_free(km, sizeof(*km));



Home | Main Index | Thread Index | Old Index