diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 95685925027c..fe9459f47692 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -147,19 +147,9 @@ malloc(size, type, flags) KASSERT(intr_nesting_level == 0, ("malloc(M_WAITOK) in interrupt context")); #endif - /* - * Must be at splmem() prior to initializing segment to handle - * potential initialization race. - */ - - s = splmem(); - - if (type->ks_limit == 0) - malloc_init(type); - indx = BUCKETINDX(size); kbp = &bucket[indx]; - + s = splmem(); while (ksp->ks_memuse >= ksp->ks_limit) { if (flags & M_ASLEEP) { if (ksp->ks_limblocks < 65535) @@ -298,9 +288,6 @@ free(addr, type) #endif register struct malloc_type *ksp = type; - if (type->ks_limit == 0) - panic("freeing with unknown type (%s)", type->ks_shortdesc); - KASSERT(kmembase <= (char *)addr && (char *)addr < kmemlimit, ("free: address %p out of range", (void *)addr)); kup = btokup(addr); diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 126b22633748..3ea2012f4ed5 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -68,7 +68,7 @@ struct malloc_type { struct malloc_type type[1] = { \ { NULL, 0, 0, 0, 0, 0, 0, M_MAGIC, shortdesc, 0, 0 } \ }; \ - SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_ANY, malloc_init, type); \ + SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, type); \ SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, malloc_uninit, type) #define MALLOC_DECLARE(type) \