[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140306211141.GA17009@redhat.com>
Date: Thu, 6 Mar 2014 16:11:41 -0500
From: Dave Jones <davej@...hat.com>
To: Linux Kernel <linux-kernel@...r.kernel.org>
Cc: linux-mm@...ck.org, cl@...ux-foundation.org, penberg@...nel.org
Subject: slub: fix leak of 'name' in sysfs_slab_add
The failure paths of sysfs_slab_add don't release the allocation of 'name'
made by create_unique_id() a few lines above the context of the diff below.
Create a common exit path to make it more obvious what needs freeing.
Signed-off-by: Dave Jones <davej@...oraproject.org>
diff --git a/mm/slub.c b/mm/slub.c
index 25f14ad8f817..b2181d2682ac 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5197,17 +5197,13 @@ static int sysfs_slab_add(struct kmem_cache *s)
s->kobj.kset = slab_kset;
err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
- if (err) {
- kobject_put(&s->kobj);
- return err;
- }
+ if (err)
+ goto err_out;
err = sysfs_create_group(&s->kobj, &slab_attr_group);
- if (err) {
- kobject_del(&s->kobj);
- kobject_put(&s->kobj);
- return err;
- }
+ if (err)
+ goto err_sysfs;
+
kobject_uevent(&s->kobj, KOBJ_ADD);
if (!unmergeable) {
/* Setup first alias */
@@ -5215,6 +5211,13 @@ static int sysfs_slab_add(struct kmem_cache *s)
kfree(name);
}
return 0;
+
+err_sysfs:
+ kobject_del(&s->kobj);
+err_out:
+ kobject_put(&s->kobj);
+ kfree(name);
+ return err;
}
static void sysfs_slab_remove(struct kmem_cache *s)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists