From 6286ae97d10ea2b5cd90532163797ab217bfdbdf Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 3 May 2013 15:43:18 +0000 Subject: slab: Return NULL for oversized allocations The inline path seems to have changed the SLAB behavior for very large kmalloc allocations with commit e3366016 ("slab: Use common kmalloc_index/kmalloc_size functions"). This patch restores the old behavior but also adds diagnostics so that we can figure where in the code these large allocations occur. Reported-and-tested-by: Tetsuo Handa Signed-off-by: Christoph Lameter Link: http://lkml.kernel.org/r/201305040348.CIF81716.OStQOHFJMFLOVF@I-love.SAKURA.ne.jp [ penberg@kernel.org: use WARN_ON_ONCE ] Signed-off-by: Pekka Enberg --- mm/slab_common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mm') diff --git a/mm/slab_common.c b/mm/slab_common.c index 2f0e7d5976cb..c5d352e73d81 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -373,6 +373,9 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags) { int index; + if (WARN_ON_ONCE(size > KMALLOC_MAX_SIZE)) + return NULL; + if (size <= 192) { if (!size) return ZERO_SIZE_PTR; -- cgit v1.2.3