mm: kmem_cache_create(): make it easier to catch NULL cache names
authorBenjamin Herrenschmidt <[email protected]>
Tue, 22 Sep 2009 00:02:30 +0000 (17:02 -0700)
committerLinus Torvalds <[email protected]>
Tue, 22 Sep 2009 14:17:33 +0000 (07:17 -0700)
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 <[email protected]>
Cc: Pekka Enberg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/slub.c

index 0a216aae227e8b3ca7daa5ab8140a2a804784181..4996fc7195528ba931dda8c042da44b2501b083e 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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) {