Skip to contentSkip to conversation

kernel/cgroup: cleanup cgroup_base_files when fail to add cgroup_psi_files

PATCH Applied David Wang 2 participants 2 messages May 17, 2024 – May 26, 2024 cgroup

lore
Share & tools
lore

David Wang

author
#0 lore raw

PATCH 1/1 kernel/cgroup: cleanup cgroup_base_files when fail to add cgroup_psi_files

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.

---
 kernel/cgroup/cgroup.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/cgroup/cgroup.c +4 -1
index a66c088c851c..6c255b5a331f 100644
@@ -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,
Signature · 1 line
2.39.2
maintainer Applied
#1 lore raw
Quoted 7 lines · David Wang

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.

Applied to cgroup/for-6.11.

Thanks.

Signature · 1 line
tejun