Skip to content

Commit

Permalink
mm: kmem_cache_create(): make it easier to catch NULL cache names
Browse files Browse the repository at this point in the history
Right now, if you inadvertently pass NULL to kmem_cache_create() at boot
time, it crashes much later after boot somewhere deep inside sysfs which
makes it very non obvious to figure out what's going on.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Benjamin Herrenschmidt authored and Linus Torvalds committed Sep 22, 2009
1 parent 398499d commit fe1ff49
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,9 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
{
struct kmem_cache *s;

if (WARN_ON(!name))
return NULL;

down_write(&slub_lock);
s = find_mergeable(size, align, flags, name, ctor);
if (s) {
Expand Down

0 comments on commit fe1ff49

Please sign in to comment.