aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorVegard Nossum <vegard.nossum@gmail.com>2007-12-05 02:45:30 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-05 12:21:20 -0500
commit294a80a8ed004b383ab214837e1c05ca4098a717 (patch)
tree2cbf9d33ccafa5042dbde85641d4ca27dcf47dc5 /mm
parent5a622f2d0f86b316b07b55a4866ecb5518dd1cf7 (diff)
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 <penberg@cs.helsinki.fi> Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Christoph Lameter <clameter@sgi.com>, Matt Mackall <mpm@selenic.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/slub.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 9acb413858ac..b9f37cb0f2e6 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2558,8 +2558,12 @@ size_t ksize(const void *object)
2558 if (unlikely(object == ZERO_SIZE_PTR)) 2558 if (unlikely(object == ZERO_SIZE_PTR))
2559 return 0; 2559 return 0;
2560 2560
2561 page = get_object_page(object); 2561 page = virt_to_head_page(object);
2562 BUG_ON(!page); 2562 BUG_ON(!page);
2563
2564 if (unlikely(!PageSlab(page)))
2565 return PAGE_SIZE << compound_order(page);
2566
2563 s = page->slab; 2567 s = page->slab;
2564 BUG_ON(!s); 2568 BUG_ON(!s);
2565 2569