From 298ff6e581295636c5f887c86d6095a1e816b6d4 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 10 Oct 2012 20:43:27 +0800 Subject: [PATCH] kmalloc: Use powerof2() to detect power-of-2 size --- sys/kern/kern_slaballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_slaballoc.c b/sys/kern/kern_slaballoc.c index 9a80068756..d23cf8cb9c 100644 --- a/sys/kern/kern_slaballoc.c +++ b/sys/kern/kern_slaballoc.c @@ -828,7 +828,7 @@ kmalloc(unsigned long size, struct malloc_type *type, int flags) * Guarentee power-of-2 alignment for power-of-2-sized chunks. * Otherwise just 8-byte align the data. */ - if ((size | (size - 1)) + 1 == (size << 1)) + if (powerof2(size)) off = (off + size - 1) & ~(size - 1); else off = (off + align - 1) & ~(align - 1); -- 2.41.0