Commit b0234a62 authored by Kenneth W. Chen's avatar Kenneth W. Chen Committed by Linus Torvalds

[PATCH] fix in slab.c:alloc_arraycache

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: default avatarKen Chen <kenneth.w.chen@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3a85d4dd
......@@ -665,8 +665,10 @@ static struct array_cache *alloc_arraycache(int cpu, int entries, int batchcount
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment