[RFC 2/4] CONFIG_STABLE: Switch off kmalloc(0) tests in slab allocators

From: clameter
Date: Wed May 30 2007 - 20:30:56 EST


We do not want kmalloc(0) to trigger stackdumps if this is a stable
kernel. kmalloc(0) is currently harmless.

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>

---
include/linux/slub_def.h | 2 ++
mm/slab.c | 2 ++
2 files changed, 4 insertions(+)

Index: slub/include/linux/slub_def.h
===================================================================
--- slub.orig/include/linux/slub_def.h 2007-05-30 16:35:05.000000000 -0700
+++ slub/include/linux/slub_def.h 2007-05-30 16:37:39.000000000 -0700
@@ -74,6 +74,7 @@ extern struct kmem_cache kmalloc_caches[
*/
static inline int kmalloc_index(size_t size)
{
+#ifndef CONFIG_STABLE
/*
* We should return 0 if size == 0 (which would result in the
* kmalloc caller to get NULL) but we use the smallest object
@@ -81,6 +82,7 @@ static inline int kmalloc_index(size_t s
* we can discover locations where we do 0 sized allocations.
*/
WARN_ON_ONCE(size == 0);
+#endif

if (size > KMALLOC_MAX_SIZE)
return -1;
Index: slub/mm/slab.c
===================================================================
--- slub.orig/mm/slab.c 2007-05-30 16:35:05.000000000 -0700
+++ slub/mm/slab.c 2007-05-30 16:37:39.000000000 -0700
@@ -774,7 +774,9 @@ static inline struct kmem_cache *__find_
*/
BUG_ON(malloc_sizes[INDEX_AC].cs_cachep == NULL);
#endif
+#ifndef CONFIG_STABLE
WARN_ON_ONCE(size == 0);
+#endif
while (size > csizep->cs_size)
csizep++;


--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/