[PATCH] Catch kmalloc failure in kmem_cache_init() (was: [QUESTION] check for mem in slab)
Hi, > On 3/30/07, Heiko Carstens <[EMAIL PROTECTED]> wrote: > >> in file mm/slab.c and routine kmem_cache_init() I found there > >> is no checking for allocated memory on line: > >> > >> /* 4) Replace the bootstrap head arrays */ > >> { > >> struct array_cache *ptr; > >> > >> ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); > >> > >> --> no check for ptr == NULL <-- > >[...] > >> is that OK? or it's a bug? > > > >It's ok. If that allocation fails your machine won't come up anyway. > > We ought to add a BUG_ON or comment at least there as this keeps > popping up again and again. Done. Patch attached. Signed-off-by: Johannes Weiner <[EMAIL PROTECTED]> diff --git a/mm/slab.c b/mm/slab.c index 57f7aa4..6d7e486 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1512,6 +1512,7 @@ void __init kmem_cache_init(void) struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); + BUG_ON(!ptr); local_irq_disable(); BUG_ON(cpu_cache_get(_cache) != _cache.cache); @@ -1526,6 +1527,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(cpu_cache_get(malloc_sizes[INDEX_AC].cs_cachep)
[PATCH] Catch kmalloc failure in kmem_cache_init() (was: [QUESTION] check for mem in slab)
Hi, On 3/30/07, Heiko Carstens [EMAIL PROTECTED] wrote: in file mm/slab.c and routine kmem_cache_init() I found there is no checking for allocated memory on line: /* 4) Replace the bootstrap head arrays */ { struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); -- no check for ptr == NULL -- [...] is that OK? or it's a bug? It's ok. If that allocation fails your machine won't come up anyway. We ought to add a BUG_ON or comment at least there as this keeps popping up again and again. Done. Patch attached. Signed-off-by: Johannes Weiner [EMAIL PROTECTED] diff --git a/mm/slab.c b/mm/slab.c index 57f7aa4..6d7e486 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1512,6 +1512,7 @@ void __init kmem_cache_init(void) struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); + BUG_ON(!ptr); local_irq_disable(); BUG_ON(cpu_cache_get(cache_cache) != initarray_cache.cache); @@ -1526,6 +1527,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(cpu_cache_get(malloc_sizes[INDEX_AC].cs_cachep)
Re: [QUESTION] check for mem in slab
[Pekka Enberg - Fri, Mar 30, 2007 at 02:55:26PM +0300] | On 3/30/07, Heiko Carstens <[EMAIL PROTECTED]> wrote: | >> in file mm/slab.c and routine kmem_cache_init() I found there | >> is no checking for allocated memory on line: | >> | >> /* 4) Replace the bootstrap head arrays */ | >> { | >> struct array_cache *ptr; | >> | >> ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); | >> | >> --> no check for ptr == NULL <-- | >[...] | >> is that OK? or it's a bug? | > | >It's ok. If that allocation fails your machine won't come up anyway. | | We ought to add a BUG_ON or comment at least there as this keeps | popping up again and again. | Thanks for answer Cyrill - 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/
Re: [QUESTION] check for mem in slab
On 3/30/07, Heiko Carstens <[EMAIL PROTECTED]> wrote: > in file mm/slab.c and routine kmem_cache_init() I found there > is no checking for allocated memory on line: > > /* 4) Replace the bootstrap head arrays */ > { > struct array_cache *ptr; > > ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); > > --> no check for ptr == NULL <-- [...] > is that OK? or it's a bug? It's ok. If that allocation fails your machine won't come up anyway. We ought to add a BUG_ON or comment at least there as this keeps popping up again and again. - 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/
Re: [QUESTION] check for mem in slab
On 3/30/07, Heiko Carstens [EMAIL PROTECTED] wrote: in file mm/slab.c and routine kmem_cache_init() I found there is no checking for allocated memory on line: /* 4) Replace the bootstrap head arrays */ { struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); -- no check for ptr == NULL -- [...] is that OK? or it's a bug? It's ok. If that allocation fails your machine won't come up anyway. We ought to add a BUG_ON or comment at least there as this keeps popping up again and again. - 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/
Re: [QUESTION] check for mem in slab
[Pekka Enberg - Fri, Mar 30, 2007 at 02:55:26PM +0300] | On 3/30/07, Heiko Carstens [EMAIL PROTECTED] wrote: | in file mm/slab.c and routine kmem_cache_init() I found there | is no checking for allocated memory on line: | |/* 4) Replace the bootstrap head arrays */ |{ |struct array_cache *ptr; | |ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); | | -- no check for ptr == NULL -- | [...] | is that OK? or it's a bug? | | It's ok. If that allocation fails your machine won't come up anyway. | | We ought to add a BUG_ON or comment at least there as this keeps | popping up again and again. | Thanks for answer Cyrill - 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/
Re: [QUESTION] check for mem in slab
> in file mm/slab.c and routine kmem_cache_init() I found there > is no checking for allocated memory on line: > > /* 4) Replace the bootstrap head arrays */ > { > struct array_cache *ptr; > > ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); > > --> no check for ptr == NULL <-- [...] > is that OK? or it's a bug? It's ok. If that allocation fails your machine won't come up anyway. - 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/
[QUESTION] check for mem in slab
Hi list, in file mm/slab.c and routine kmem_cache_init() I found there is no checking for allocated memory on line: /* 4) Replace the bootstrap head arrays */ { struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); --> no check for ptr == NULL <-- local_irq_disable(); BUG_ON(cpu_cache_get(_cache) != _cache.cache); memcpy(ptr, cpu_cache_get(_cache), sizeof(struct arraycache_init)); ... is that OK? or it's a bug? Cyrill - 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/
[QUESTION] check for mem in slab
Hi list, in file mm/slab.c and routine kmem_cache_init() I found there is no checking for allocated memory on line: /* 4) Replace the bootstrap head arrays */ { struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); -- no check for ptr == NULL -- local_irq_disable(); BUG_ON(cpu_cache_get(cache_cache) != initarray_cache.cache); memcpy(ptr, cpu_cache_get(cache_cache), sizeof(struct arraycache_init)); ... is that OK? or it's a bug? Cyrill - 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/
Re: [QUESTION] check for mem in slab
in file mm/slab.c and routine kmem_cache_init() I found there is no checking for allocated memory on line: /* 4) Replace the bootstrap head arrays */ { struct array_cache *ptr; ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); -- no check for ptr == NULL -- [...] is that OK? or it's a bug? It's ok. If that allocation fails your machine won't come up anyway. - 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/