Эх сурвалжийг харах

[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" <davem@davemloft.net>
Cc: Christoph Lameter <christoph@lameter.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Andrew Morton 19 жил өмнө
parent
commit
dbdb904500
1 өөрчлөгдсөн 2 нэмэгдсэн , 1 устгасан
  1. 2 1
      mm/slab.c

+ 2 - 1
mm/slab.c

@@ -2907,7 +2907,8 @@ void *__kmalloc(size_t size, unsigned int __nocast flags)
 	 * functions.
 	 * functions.
 	 */
 	 */
 	cachep = __find_general_cachep(size, flags);
 	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);
 	return __cache_alloc(cachep, flags);
 }
 }
 EXPORT_SYMBOL(__kmalloc);
 EXPORT_SYMBOL(__kmalloc);