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: http://pilppa.com/gitweb/?a=commitdiff_plain;h=dbdb90450059e17e8e005ebd3ce0a1fd6008a0c8;p=linux-2.6-omap-h63xx.git [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 ad113c431e3..c9adfce0040 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);