slub: release kobject if sysfs_create_group failed in sysfs_slab_add
authorXiaotian Feng <dfeng@redhat.com>
Wed, 22 Jul 2009 03:28:53 +0000 (11:28 +0800)
committerPekka Enberg <penberg@cs.helsinki.fi>
Thu, 3 Sep 2009 18:11:41 +0000 (21:11 +0300)
When CONFIG_SLUB_DEBUG is enabled, sysfs_slab_add should unlink and put the
kobject if sysfs_create_group failed. Otherwise, sysfs_slab_add returns error
then free kmem_cache s, thus memory of s->kobj is leaked.

Acked-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
mm/slub.c

index be493bd63c316914ab1789228bfd28e8f7de493d..d73f771d278fc6eec475e34621f735c0cfda8661 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4593,8 +4593,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
        }
 
        err = sysfs_create_group(&s->kobj, &slab_attr_group);
-       if (err)
+       if (err) {
+               kobject_del(&s->kobj);
+               kobject_put(&s->kobj);
                return err;
+       }
        kobject_uevent(&s->kobj, KOBJ_ADD);
        if (!unmergeable) {
                /* Setup first alias */