bootmem: avoid freeing to bootmem after bootmem is done
[cascardo/linux.git] / mm / slab_common.c
index c26829f..5ce4fae 100644 (file)
@@ -500,7 +500,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg,
                             struct kmem_cache *root_cache)
 {
        static char memcg_name_buf[NAME_MAX + 1]; /* protected by slab_mutex */
-       struct cgroup_subsys_state *css = mem_cgroup_css(memcg);
+       struct cgroup_subsys_state *css = &memcg->css;
        struct memcg_cache_array *arr;
        struct kmem_cache *s = NULL;
        char *cache_name;
@@ -640,6 +640,9 @@ void kmem_cache_destroy(struct kmem_cache *s)
        bool need_rcu_barrier = false;
        bool busy = false;
 
+       if (unlikely(!s))
+               return;
+
        BUG_ON(!is_root_cache(s));
 
        get_online_cpus();