Commit 5788d8ad authored by Xiaotian Feng's avatar Xiaotian Feng Committed by Pekka Enberg

slub: release kobject if sysfs_create_group failed in sysfs_slab_add

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: default avatarChristoph Lameter <cl@linux-foundation.org>
Signed-off-by: default avatarXiaotian Feng <dfeng@redhat.com>
Signed-off-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
parent acdfcd04
...@@ -4593,8 +4593,11 @@ static int sysfs_slab_add(struct kmem_cache *s) ...@@ -4593,8 +4593,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
} }
err = sysfs_create_group(&s->kobj, &slab_attr_group); err = sysfs_create_group(&s->kobj, &slab_attr_group);
if (err) if (err) {
kobject_del(&s->kobj);
kobject_put(&s->kobj);
return err; return err;
}
kobject_uevent(&s->kobj, KOBJ_ADD); kobject_uevent(&s->kobj, KOBJ_ADD);
if (!unmergeable) { if (!unmergeable) {
/* Setup first alias */ /* Setup first alias */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment