summaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux-foundation.org>2010-07-09 14:07:12 -0500
committerPekka Enberg <penberg@cs.helsinki.fi>2010-07-16 11:13:07 +0300
commitd7278bd7d1aab5c6d35fd271eeb860548f0bd0bb (patch)
tree24f82cf0c312c69291b7f4ed4879a0a345558cac /mm/slub.c
parentf90ec390148fdbc0db38c477bc6dc94db721e7f1 (diff)
downloadop-kernel-dev-d7278bd7d1aab5c6d35fd271eeb860548f0bd0bb.zip
op-kernel-dev-d7278bd7d1aab5c6d35fd271eeb860548f0bd0bb.tar.gz
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>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 2c11903..8655be5 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3118,9 +3118,12 @@ void __init kmem_cache_init(void)
slab_state = UP;
/* Provide the correct kmalloc names now that the caches are up */
- for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++)
- kmalloc_caches[i]. name =
- kasprintf(GFP_NOWAIT, "kmalloc-%d", 1 << i);
+ for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
+ char *s = kasprintf(GFP_NOWAIT, "kmalloc-%d", 1 << i);
+
+ BUG_ON(!s);
+ kmalloc_caches[i].name = s;
+ }
#ifdef CONFIG_SMP
register_cpu_notifier(&slab_notifier);
OpenPOWER on IntegriCloud