From: Andrew Morton Date: Fri, 23 Sep 2005 20:24:10 +0000 (-0700) Subject: [PATCH] revert oversized kmalloc check X-Git-Tag: v2.6.14-rc3~51^2~8 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbdb90450059e17e8e005ebd3ce0a1fd6008a0c8;p=linux-2.6 [PATCH] revert oversized kmalloc check As davem points out, this wasn't such a great idea. There may be some code which does: size = 1024*1024; while (kmalloc(size, ...) == 0) size /= 2; which will now explode. Cc: "David S. Miller" Cc: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/slab.c b/mm/slab.c index ad113c431e..c9adfce004 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2907,7 +2907,8 @@ void *__kmalloc(size_t size, unsigned int __nocast flags) * functions. */ cachep = __find_general_cachep(size, flags); - BUG_ON(!cachep); /* Allocation size too large for kmalloc */ + if (unlikely(cachep == NULL)) + return NULL; return __cache_alloc(cachep, flags); } EXPORT_SYMBOL(__kmalloc);