Skip to content

Commit a68fc0c

Browse files
htejungregkh
authored andcommitted
cgroup: fix error return from cgroup_create()
commit b58c899 upstream. cgroup_create() was returning 0 after allocation failures. Fix it. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 95efbc2 commit a68fc0c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎kernel/cgroup.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,7 +4348,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
43484348
struct cgroup *cgrp;
43494349
struct cgroup_name *name;
43504350
struct cgroupfs_root *root = parent->root;
4351-
int err = 0;
4351+
int err;
43524352
struct cgroup_subsys *ss;
43534353
struct super_block *sb = root->sb;
43544354

@@ -4358,17 +4358,21 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
43584358
return -ENOMEM;
43594359

43604360
name = cgroup_alloc_name(dentry);
4361-
if (!name)
4361+
if (!name) {
4362+
err = -ENOMEM;
43624363
goto err_free_cgrp;
4364+
}
43634365
rcu_assign_pointer(cgrp->name, name);
43644366

43654367
/*
43664368
* Temporarily set the pointer to NULL, so idr_find() won't return
43674369
* a half-baked cgroup.
43684370
*/
43694371
cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL);
4370-
if (cgrp->id < 0)
4372+
if (cgrp->id < 0) {
4373+
err = -ENOMEM;
43714374
goto err_free_name;
4375+
}
43724376

43734377
/*
43744378
* Only live parents can have children. Note that the liveliness

0 commit comments

Comments
 (0)