Commit 35fcf4dd authored by Tejun Heo's avatar Tejun Heo Committed by Jiri Slaby

cgroup: fix error return from cgroup_create()

commit b58c8998 upstream.

cgroup_create() was returning 0 after allocation failures.  Fix it.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarLi Zefan <lizefan@huawei.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 7737f595
......@@ -4395,7 +4395,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
struct cgroup *cgrp;
struct cgroup_name *name;
struct cgroupfs_root *root = parent->root;
int err = 0;
int err;
struct cgroup_subsys *ss;
struct super_block *sb = root->sb;
......@@ -4405,8 +4405,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
return -ENOMEM;
name = cgroup_alloc_name(dentry);
if (!name)
if (!name) {
err = -ENOMEM;
goto err_free_cgrp;
}
rcu_assign_pointer(cgrp->name, name);
/*
......@@ -4414,8 +4416,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
* a half-baked cgroup.
*/
cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL);
if (cgrp->id < 0)
if (cgrp->id < 0) {
err = -ENOMEM;
goto err_free_name;
}
/*
* Only live parents can have children. Note that the liveliness
......
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