summaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorChristoph Lameter2007-10-16 10:24:46 +0200
committerLinus Torvalds2007-10-16 18:42:53 +0200
commitef8b4520bd9f8294ffce9abd6158085bde5dc902 (patch)
treec099a16691ac06208f4d3d65b71e7adaf7361fcd /mm/slub.c
parentcalculation of pgoff in do_linear_fault() uses mixed units (diff)
downloadkernel-qcow2-linux-ef8b4520bd9f8294ffce9abd6158085bde5dc902.tar.gz
kernel-qcow2-linux-ef8b4520bd9f8294ffce9abd6158085bde5dc902.tar.xz
kernel-qcow2-linux-ef8b4520bd9f8294ffce9abd6158085bde5dc902.zip
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/slub.c')
-rw-r--r--mm/slub.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/slub.c b/mm/slub.c
index b7d3664fa3a9..d7c044dbd157 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2449,7 +2449,8 @@ size_t ksize(const void *object)
struct page *page;
struct kmem_cache *s;
- if (unlikely(ZERO_OR_NULL_PTR(object)))
+ BUG_ON(!object);
+ if (unlikely(object == ZERO_SIZE_PTR))
return 0;
page = get_object_page(object);