diff options
author | Christoph Lameter <clameter@sgi.com> | 2007-10-16 04:24:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:42:53 -0400 |
commit | ef8b4520bd9f8294ffce9abd6158085bde5dc902 (patch) | |
tree | c099a16691ac06208f4d3d65b71e7adaf7361fcd /mm/slob.c | |
parent | 0da7e01f5f37f441cccd7c8c0586e06db0981907 (diff) |
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 <clameter@sgi.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: 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/slob.c')
-rw-r--r-- | mm/slob.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -484,7 +484,8 @@ size_t ksize(const void *block) | |||
484 | { | 484 | { |
485 | struct slob_page *sp; | 485 | struct slob_page *sp; |
486 | 486 | ||
487 | if (unlikely(ZERO_OR_NULL_PTR(block))) | 487 | BUG_ON(!block); |
488 | if (unlikely(block == ZERO_SIZE_PTR)) | ||
488 | return 0; | 489 | return 0; |
489 | 490 | ||
490 | sp = (struct slob_page *)virt_to_page(block); | 491 | sp = (struct slob_page *)virt_to_page(block); |