cgroup: fix error return from cgroup_create()
authorTejun Heo <tj@kernel.org>
Sat, 8 Feb 2014 15:26:33 +0000 (10:26 -0500)
committerTejun Heo <tj@kernel.org>
Sat, 8 Feb 2014 15:26:33 +0000 (10:26 -0500)
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>
Cc: stable@vger.kernel.org
kernel/cgroup.c

index 793f371760779b2ff7ffd66d615bb82dc02d9435..0eb7b868e1abfb5f64137ab5cf63beba5be98003 100644 (file)
@@ -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;
 
@@ -4168,8 +4168,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);
 
        /*
@@ -4177,8 +4179,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