cgroup: fix error return from cgroup_create()
authorTejun Heo <tj@kernel.org>
Sat, 8 Feb 2014 15:26:33 +0000 (10:26 -0500)
committerJiri Slaby <jslaby@suse.cz>
Wed, 5 Mar 2014 16:13:43 +0000 (17:13 +0100)
commit b58c89986a77a23658682a100eb15d8edb571ebb 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: Jiri Slaby <jslaby@suse.cz>
kernel/cgroup.c

index 8ea46f2c4b5157cb09ba9ae9e630580771688255..8103e8b66221ec76a36e158b2d872c80e2820efd 100644 (file)
@@ -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