Skip to content

Commit b58c899

Browse files
committed
cgroup: fix error return from cgroup_create()
cgroup_create() was returning 0 after allocation failures. Fix it. Signed-off-by: Tejun Heo <[email protected]> Acked-by: Li Zefan <[email protected]> Cc: [email protected]
1 parent eb46bf8 commit b58c899

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kernel/cgroup.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4158,7 +4158,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
41584158
struct cgroup *cgrp;
41594159
struct cgroup_name *name;
41604160
struct cgroupfs_root *root = parent->root;
4161-
int ssid, err = 0;
4161+
int ssid, err;
41624162
struct cgroup_subsys *ss;
41634163
struct super_block *sb = root->sb;
41644164

@@ -4168,17 +4168,21 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
41684168
return -ENOMEM;
41694169

41704170
name = cgroup_alloc_name(dentry);
4171-
if (!name)
4171+
if (!name) {
4172+
err = -ENOMEM;
41724173
goto err_free_cgrp;
4174+
}
41734175
rcu_assign_pointer(cgrp->name, name);
41744176

41754177
/*
41764178
* Temporarily set the pointer to NULL, so idr_find() won't return
41774179
* a half-baked cgroup.
41784180
*/
41794181
cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL);
4180-
if (cgrp->id < 0)
4182+
if (cgrp->id < 0) {
4183+
err = -ENOMEM;
41814184
goto err_free_name;
4185+
}
41824186

41834187
/*
41844188
* Only live parents can have children. Note that the liveliness

0 commit comments

Comments
 (0)