cgroup: fix error return value in cgroup_mount()
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)
When cgroup_mount() fails to allocate an id for the root, it didn't
set ret before jumping to unlock_drop ending up returning 0 after a
failure.  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 aa95591c14304e13fece8b9b54e397b1c7e23f04..793f371760779b2ff7ffd66d615bb82dc02d9435 100644 (file)
@@ -1566,10 +1566,10 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
                mutex_lock(&cgroup_mutex);
                mutex_lock(&cgroup_root_mutex);
 
-               root_cgrp->id = idr_alloc(&root->cgroup_idr, root_cgrp,
-                                          0, 1, GFP_KERNEL);
-               if (root_cgrp->id < 0)
+               ret = idr_alloc(&root->cgroup_idr, root_cgrp, 0, 1, GFP_KERNEL);
+               if (ret < 0)
                        goto unlock_drop;
+               root_cgrp->id = ret;
 
                /* Check for name clashes with existing mounts */
                ret = -EBUSY;