lkml.org 
[lkml]   [2009]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] mm: Add kmalloc NULL tests
Hello Julia,

On Thu, Jul 30, 2009 at 04:10:22PM +0200, Julia Lawall wrote:

> diff --git a/mm/slab.c b/mm/slab.c
> index 7b5d4de..972e427 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1502,6 +1502,7 @@ void __init kmem_cache_init(void)
>
> ptr = kmalloc(sizeof(struct arraycache_init), GFP_NOWAIT);
>
> + BUG_ON(!ptr);
> BUG_ON(cpu_cache_get(&cache_cache) != &initarray_cache.cache);
> memcpy(ptr, cpu_cache_get(&cache_cache),
> sizeof(struct arraycache_init));

This does not change the end result when the allocation fails: you get
a stacktrace and a kernel panic. Leaving it as is saves a line of
code.

> @@ -1514,6 +1515,7 @@ void __init kmem_cache_init(void)
>
> ptr = kmalloc(sizeof(struct arraycache_init), GFP_NOWAIT);
>
> + BUG_ON(!ptr);
> BUG_ON(cpu_cache_get(malloc_sizes[INDEX_AC].cs_cachep)
> != &initarray_generic.cache);
> memcpy(ptr, cpu_cache_get(malloc_sizes[INDEX_AC].cs_cachep),

Hannes


\
 
 \ /
  Last update: 2009-07-30 17:41    [W:0.076 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site