slub: fix a possible memory leak
Joonsoo Kim [Thu, 10 May 2012 15:32:59 +0000 (00:32 +0900)]
Memory allocated by kstrdup should be freed,
when kmalloc(kmem_size, GFP_KERNEL) is failed.

Acked-by: Christoph Lameter <cl@linux.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>

mm/slub.c

index 18bf13e..60119f7 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3968,9 +3968,9 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
                        }
                        return s;
                }
-               kfree(n);
                kfree(s);
        }
+       kfree(n);
 err:
        up_write(&slub_lock);