aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-10-16 04:24:46 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:42:53 -0400
commitef8b4520bd9f8294ffce9abd6158085bde5dc902 (patch)
treec099a16691ac06208f4d3d65b71e7adaf7361fcd /mm/slab.c
parent0da7e01f5f37f441cccd7c8c0586e06db0981907 (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/slab.c')
-rw-r--r--mm/slab.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 6f6abef83a1a..1b240a3029d6 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4446,7 +4446,8 @@ const struct seq_operations slabstats_op = {
4446 */ 4446 */
4447size_t ksize(const void *objp) 4447size_t ksize(const void *objp)
4448{ 4448{
4449 if (unlikely(ZERO_OR_NULL_PTR(objp))) 4449 BUG_ON(!objp);
4450 if (unlikely(objp == ZERO_SIZE_PTR))
4450 return 0; 4451 return 0;
4451 4452
4452 return obj_size(virt_to_cache(objp)); 4453 return obj_size(virt_to_cache(objp));