From ef8b4520bd9f8294ffce9abd6158085bde5dc902 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Tue, 16 Oct 2007 01:24:46 -0700 Subject: Slab allocators: fail if ksize is called with a NULL parameter A NULL pointer means that the object was not allocated. One cannot determine the size of an object that has not been allocated. Currently we return 0 but we really should BUG() on attempts to determine the size of something nonexistent. krealloc() interprets NULL to mean a zero sized object. Handle that separately in krealloc(). Signed-off-by: Christoph Lameter Acked-by: Pekka Enberg Cc: Matt Mackall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/slob.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mm/slob.c') diff --git a/mm/slob.c b/mm/slob.c index a886e83..de5d556 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -484,7 +484,8 @@ size_t ksize(const void *block) { struct slob_page *sp; - if (unlikely(ZERO_OR_NULL_PTR(block))) + BUG_ON(!block); + if (unlikely(block == ZERO_SIZE_PTR)) return 0; sp = (struct slob_page *)virt_to_page(block); -- cgit v1.1