diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -609,12 +609,15 @@ } static caddr_t __noinline -malloc_large(size_t size, struct malloc_type *mtp, struct domainset *policy, +malloc_large(size_t _size, struct malloc_type *mtp, struct domainset *policy, int flags DEBUG_REDZONE_ARG_DEF) { void *va; + size_t size; - size = roundup(size, PAGE_SIZE); + size = round_page(_size); + if (__predict_false(size < _size)) + return (NULL); va = kmem_malloc_domainset(policy, size, flags); if (va != NULL) { /* Use low bits unused for slab pointers. */ @@ -1125,10 +1128,14 @@ * specified size */ size_t -malloc_size(size_t size) +malloc_size(size_t _size) { + size_t size; int indx; + size = round_page(_size); + if (size < _size) + return (0); if (size > kmem_zmax) return (round_page(size)); if (size & KMEM_ZMASK)