[PATCH] slab: Adds two missing kmalloc() checks.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Adds two missing kmalloc() checks in kmem_cache_init(). The check is worth
because if kmalloc() fails we'll have a nice message instead of a OOPS (which
will make us look for a bug).

 We're using BUG_ON() so that embedded people can disable it.

Signed-off-by: Luiz Capitulino <[email protected]>

 mm/slab.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/slab.c b/mm/slab.c
index 6f8495e..2fcfd08 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1130,6 +1130,7 @@ void __init kmem_cache_init(void)
 		void *ptr;
 
 		ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
+		BUG_ON(!ptr);
 
 		local_irq_disable();
 		BUG_ON(ac_data(&cache_cache) != &initarray_cache.cache);
@@ -1139,6 +1140,7 @@ void __init kmem_cache_init(void)
 		local_irq_enable();
 
 		ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
+		BUG_ON(!ptr);
 
 		local_irq_disable();
 		BUG_ON(ac_data(malloc_sizes[INDEX_AC].cs_cachep)


-- 
Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux