diff options
-rw-r--r-- | mm/slub.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -2192,12 +2192,13 @@ void kmem_cache_destroy(struct kmem_cache *s) | |||
2192 | s->refcount--; | 2192 | s->refcount--; |
2193 | if (!s->refcount) { | 2193 | if (!s->refcount) { |
2194 | list_del(&s->list); | 2194 | list_del(&s->list); |
2195 | up_write(&slub_lock); | ||
2195 | if (kmem_cache_close(s)) | 2196 | if (kmem_cache_close(s)) |
2196 | WARN_ON(1); | 2197 | WARN_ON(1); |
2197 | sysfs_slab_remove(s); | 2198 | sysfs_slab_remove(s); |
2198 | kfree(s); | 2199 | kfree(s); |
2199 | } | 2200 | } else |
2200 | up_write(&slub_lock); | 2201 | up_write(&slub_lock); |
2201 | } | 2202 | } |
2202 | EXPORT_SYMBOL(kmem_cache_destroy); | 2203 | EXPORT_SYMBOL(kmem_cache_destroy); |
2203 | 2204 | ||
@@ -2679,25 +2680,26 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, | |||
2679 | */ | 2680 | */ |
2680 | s->objsize = max(s->objsize, (int)size); | 2681 | s->objsize = max(s->objsize, (int)size); |
2681 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); | 2682 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); |
2683 | up_write(&slub_lock); | ||
2682 | if (sysfs_slab_alias(s, name)) | 2684 | if (sysfs_slab_alias(s, name)) |
2683 | goto err; | 2685 | goto err; |
2684 | } else { | 2686 | return s; |
2685 | s = kmalloc(kmem_size, GFP_KERNEL); | 2687 | } |
2686 | if (s && kmem_cache_open(s, GFP_KERNEL, name, | 2688 | s = kmalloc(kmem_size, GFP_KERNEL); |
2689 | if (s) { | ||
2690 | if (kmem_cache_open(s, GFP_KERNEL, name, | ||
2687 | size, align, flags, ctor)) { | 2691 | size, align, flags, ctor)) { |
2688 | if (sysfs_slab_add(s)) { | ||
2689 | kfree(s); | ||
2690 | goto err; | ||
2691 | } | ||
2692 | list_add(&s->list, &slab_caches); | 2692 | list_add(&s->list, &slab_caches); |
2693 | } else | 2693 | up_write(&slub_lock); |
2694 | kfree(s); | 2694 | if (sysfs_slab_add(s)) |
2695 | goto err; | ||
2696 | return s; | ||
2697 | } | ||
2698 | kfree(s); | ||
2695 | } | 2699 | } |
2696 | up_write(&slub_lock); | 2700 | up_write(&slub_lock); |
2697 | return s; | ||
2698 | 2701 | ||
2699 | err: | 2702 | err: |
2700 | up_write(&slub_lock); | ||
2701 | if (flags & SLAB_PANIC) | 2703 | if (flags & SLAB_PANIC) |
2702 | panic("Cannot create slabcache %s\n", name); | 2704 | panic("Cannot create slabcache %s\n", name); |
2703 | else | 2705 | else |