public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] check return value of kmalloc() in setup_cpu_cache()
@ 2006-08-13 10:16 Akinobu Mita
  2006-08-14 23:08 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2006-08-13 10:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Pekka Enberg

This patch makes crash happen when allocation of cpucache data fails
in setup_cpu_cache(). It is a bit better than getting kernel NULL
pointer dereference later.

CC: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>

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

Index: work-failmalloc/mm/slab.c
===================================================================
--- work-failmalloc.orig/mm/slab.c
+++ work-failmalloc/mm/slab.c
@@ -1932,6 +1932,7 @@ static void setup_cpu_cache(struct kmem_
 	} else {
 		cachep->array[smp_processor_id()] =
 			kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
+		BUG_ON(!cachep->array[smp_processor_id()]);
 
 		if (g_cpucache_up == PARTIAL_AC) {
 			set_up_list3s(cachep, SIZE_L3);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] check return value of kmalloc() in setup_cpu_cache()
  2006-08-13 10:16 [PATCH] check return value of kmalloc() in setup_cpu_cache() Akinobu Mita
@ 2006-08-14 23:08 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2006-08-14 23:08 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: linux-kernel, Pekka Enberg

On Sun, 13 Aug 2006 18:16:54 +0800
Akinobu Mita <mita@miraclelinux.com> wrote:

> This patch makes crash happen when allocation of cpucache data fails
> in setup_cpu_cache(). It is a bit better than getting kernel NULL
> pointer dereference later.

This code is called on the kmem_cache_create() path.  We should back out
and return -ENOMEM from kmem_cache_create().


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-14 23:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-13 10:16 [PATCH] check return value of kmalloc() in setup_cpu_cache() Akinobu Mita
2006-08-14 23:08 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox