slab: fix wrong retval on kmem_cache_create_memcg error path
[cascardo/linux.git] / mm / slab_common.c
index 8e40321..1ec3c61 100644 (file)
@@ -233,14 +233,17 @@ out_unlock:
        mutex_unlock(&slab_mutex);
        put_online_cpus();
 
-       /*
-        * There is no point in flooding logs with warnings or especially
-        * crashing the system if we fail to create a cache for a memcg. In
-        * this case we will be accounting the memcg allocation to the root
-        * cgroup until we succeed to create its own cache, but it isn't that
-        * critical.
-        */
-       if (err && !memcg) {
+       if (err) {
+               /*
+                * There is no point in flooding logs with warnings or
+                * especially crashing the system if we fail to create a cache
+                * for a memcg. In this case we will be accounting the memcg
+                * allocation to the root cgroup until we succeed to create its
+                * own cache, but it isn't that critical.
+                */
+               if (!memcg)
+                       return NULL;
+
                if (flags & SLAB_PANIC)
                        panic("kmem_cache_create: Failed to create slab '%s'. Error %d\n",
                                name, err);