Skip to content

Commit

Permalink
cgroup: fix error return from cgroup_create()
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
htejun committed Feb 8, 2014
1 parent eb46bf8 commit b58c899
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4158,7 +4158,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 ssid, err = 0;
int ssid, err;
struct cgroup_subsys *ss;
struct super_block *sb = root->sb;

Expand All @@ -4168,17 +4168,21 @@ 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);

/*
* Temporarily set the pointer to NULL, so idr_find() won't return
* 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
Expand Down

0 comments on commit b58c899

Please sign in to comment.