cgroup: fix a leak when percpu_ref_init() fails
authorLi Zefan <lizefan@huawei.com>
Wed, 31 Jul 2013 08:16:28 +0000 (16:16 +0800)
committerTejun Heo <tj@kernel.org>
Wed, 31 Jul 2013 10:13:25 +0000 (06:13 -0400)
ss->css_free() is not called when perfcpu_ref_init() fails.

Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup.c

index afb8d53ca6c7f2cdd52948f9ec5c87a534c1546d..468e410f9e612099e52eb794629563ca14dd9c3c 100644 (file)
@@ -4344,8 +4344,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
                }
 
                err = percpu_ref_init(&css->refcnt, css_release);
-               if (err)
+               if (err) {
+                       ss->css_free(cgrp);
                        goto err_free_all;
+               }
 
                init_cgroup_css(css, ss, cgrp);