Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7278bd7 authored by Christoph Lameter's avatar Christoph Lameter Committed by Pekka Enberg
Browse files

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: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarChristoph Lameter <cl@linux-foundation.org>
Signed-off-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
parent f90ec390
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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);