From: Andrew Morton Date: Fri, 23 Sep 2005 20:24:10 +0000 (-0700) Subject: [PATCH] revert oversized kmalloc check X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dbdb90450059e17e8e005ebd3ce0a1fd6008a0c8;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.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 ad113c431e39..c9adfce00405 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);