]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
kernel/cgroup: cleanup cgroup_base_files when fail to add cgroup_psi_files
authorDavid Wang <00107082@163.com>
Fri, 17 May 2024 06:24:05 +0000 (14:24 +0800)
committerTejun Heo <tj@kernel.org>
Sun, 26 May 2024 18:48:11 +0000 (08:48 -1000)
Even though css_clear_dir would be called to cleanup
all existing cgroup files when css_populate_dir failed,
reclaiming newly created cgroup files before
css_populate_dir returns with failure makes code more
consistent.

Signed-off-by: David Wang <00107082@163.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c

index 9c9943ea5f89d2b0c6384ee7d878b34a2b5ea493..4abd817b0c7cde1cfb822f21cf508f3621f52856 100644 (file)
@@ -1744,8 +1744,11 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
                        if (cgroup_psi_enabled()) {
                                ret = cgroup_addrm_files(css, cgrp,
                                                         cgroup_psi_files, true);
-                               if (ret < 0)
+                               if (ret < 0) {
+                                       cgroup_addrm_files(css, cgrp,
+                                                          cgroup_base_files, false);
                                        return ret;
+                               }
                        }
                } else {
                        ret = cgroup_addrm_files(css, cgrp,