Allow small values of HASH_BITS to be configured From: Catalin Marinas The original implementation was assuming that the HASH_BITS value is small big enough so that the page order is at least 0. This patch corrects this. Signed-off-by: Catalin Marinas --- mm/memleak.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/memleak.c b/mm/memleak.c index 0b5aa0c..a65d930 100644 --- a/mm/memleak.c +++ b/mm/memleak.c @@ -180,12 +180,15 @@ #define OBJECT_TYPE_GUESSED 0x2 /* Hash functions */ static void hash_init(void) { - int i; - int hash_size = sizeof(*pointer_hash) * (1 << HASH_BITS); - int hash_order = fls(hash_size) - 1; + unsigned int i; + unsigned int hash_size = sizeof(*pointer_hash) * (1 << HASH_BITS); + unsigned int hash_order = fls(hash_size) - 1; + /* hash_size not a power of 2 */ if (hash_size & ((1 << hash_order) - 1)) hash_order += 1; + if (hash_order < PAGE_SHIFT) + hash_order = PAGE_SHIFT; pointer_hash = (struct hlist_head *) __get_free_pages(GFP_ATOMIC, hash_order - PAGE_SHIFT);