From: Vegard Nossum Date: Wed, 5 Dec 2007 07:45:30 +0000 (-0800) Subject: SLUB's ksize() fails for size > 2048 X-Git-Tag: v2.6.24-rc5~72 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=294a80a8ed004b383ab214837e1c05ca4098a717;p=linux-2.6-omap-h63xx.git SLUB's ksize() fails for size > 2048 I can't pass memory allocated by kmalloc() to ksize() if it is allocated by SLUB allocator and size is larger than (I guess) PAGE_SIZE / 2. The error of ksize() seems to be that it does not check if the allocation was made by SLUB or the page allocator. Reviewed-by: Pekka Enberg Tested-by: Tetsuo Handa Cc: Christoph Lameter , Matt Mackall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/slub.c b/mm/slub.c index 9acb413858a..b9f37cb0f2e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2558,8 +2558,12 @@ size_t ksize(const void *object) if (unlikely(object == ZERO_SIZE_PTR)) return 0; - page = get_object_page(object); + page = virt_to_head_page(object); BUG_ON(!page); + + if (unlikely(!PageSlab(page))) + return PAGE_SIZE << compound_order(page); + s = page->slab; BUG_ON(!s);