diff options
author | Christoph Lameter <cl@linux-foundation.org> | 2010-07-09 15:07:12 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@cs.helsinki.fi> | 2010-07-16 04:13:07 -0400 |
commit | d7278bd7d1aab5c6d35fd271eeb860548f0bd0bb (patch) | |
tree | 24f82cf0c312c69291b7f4ed4879a0a345558cac | |
parent | f90ec390148fdbc0db38c477bc6dc94db721e7f1 (diff) |
slub: Check kasprintf results in kmem_cache_init()
Small allocations may fail during slab bringup which is fatal. Add a BUG_ON()
so that we fail immediately rather than failing later during sysfs
processing.
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
-rw-r--r-- | mm/slub.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -3118,9 +3118,12 @@ void __init kmem_cache_init(void) | |||
3118 | slab_state = UP; | 3118 | slab_state = UP; |
3119 | 3119 | ||
3120 | /* Provide the correct kmalloc names now that the caches are up */ | 3120 | /* Provide the correct kmalloc names now that the caches are up */ |
3121 | for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) | 3121 | for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) { |
3122 | kmalloc_caches[i]. name = | 3122 | char *s = kasprintf(GFP_NOWAIT, "kmalloc-%d", 1 << i); |
3123 | kasprintf(GFP_NOWAIT, "kmalloc-%d", 1 << i); | 3123 | |
3124 | BUG_ON(!s); | ||
3125 | kmalloc_caches[i].name = s; | ||
3126 | } | ||
3124 | 3127 | ||
3125 | #ifdef CONFIG_SMP | 3128 | #ifdef CONFIG_SMP |
3126 | register_cpu_notifier(&slab_notifier); | 3129 | register_cpu_notifier(&slab_notifier); |