Skip to content

Commit

Permalink
slub: fix ksize() for zero-sized pointers
Browse files Browse the repository at this point in the history
The slab and slob allocators already did this right, but slub would call
"get_object_page()" on the magic ZERO_SIZE_PTR, with all kinds of nasty
end results.

Noted by Ingo Molnar.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Linus Torvalds committed Jul 19, 2007
1 parent a5c96d8 commit 9550b10
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@ size_t ksize(const void *object)
struct page *page;
struct kmem_cache *s;

if (object == ZERO_SIZE_PTR)
if (ZERO_OR_NULL_PTR(object))
return 0;

page = get_object_page(object);
Expand Down

0 comments on commit 9550b10

Please sign in to comment.