aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/slub.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 704cfa34f9ab..d057ceb3645f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3124,8 +3124,12 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3124 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); 3124 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
3125 up_write(&slub_lock); 3125 up_write(&slub_lock);
3126 3126
3127 if (sysfs_slab_alias(s, name)) 3127 if (sysfs_slab_alias(s, name)) {
3128 down_write(&slub_lock);
3129 s->refcount--;
3130 up_write(&slub_lock);
3128 goto err; 3131 goto err;
3132 }
3129 return s; 3133 return s;
3130 } 3134 }
3131 3135
@@ -3135,8 +3139,13 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3135 size, align, flags, ctor)) { 3139 size, align, flags, ctor)) {
3136 list_add(&s->list, &slab_caches); 3140 list_add(&s->list, &slab_caches);
3137 up_write(&slub_lock); 3141 up_write(&slub_lock);
3138 if (sysfs_slab_add(s)) 3142 if (sysfs_slab_add(s)) {
3143 down_write(&slub_lock);
3144 list_del(&s->list);
3145 up_write(&slub_lock);
3146 kfree(s);
3139 goto err; 3147 goto err;
3148 }
3140 return s; 3149 return s;
3141 } 3150 }
3142 kfree(s); 3151 kfree(s);