Bug fix in slab.c:alloc_arraycache

From: Chen, Kenneth W
Date: Tue Mar 08 2005 - 22:15:31 EST


Kmem_cache_alloc_node is not capable of handling a null cachep
pointer as its input argument.

If I try to increase a slab limit by echoing a very large number
into /proc/slabinfo, kernel will panic from alloc_arraycache()
because Kmem_find_general_cachep() can actually return a NULL
pointer if the size argument is sufficiently large.

Signed-off-by: Ken Chen <kenneth.w.chen@xxxxxxxxx>


--- linux-2.6.11/mm/slab.c Mon Oct 18 14:55:43 2004
+++ linux-2.6.11.ken/mm/slab.c Tue Mar 1 19:14:07 2005
@@ -643,8 +645,10 @@
struct array_cache *nc = NULL;

if (cpu != -1) {
- nc = kmem_cache_alloc_node(kmem_find_general_cachep(memsize,
- GFP_KERNEL), cpu_to_node(cpu));
+ kmem_cache_t * cachep;
+ cachep = kmem_find_general_cachep(memsize, GFP_KERNEL);
+ if (cachep)
+ nc = kmem_cache_alloc_node(cachep, cpu_to_node(cpu));
}
if (!nc)
nc = kmalloc(memsize, GFP_KERNEL);


-
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/