cgroup: Check for ret during cgroup1_base_files cft addition
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 12 Sep 2023 07:04:34 +0000 (12:34 +0530)
committerTejun Heo <tj@kernel.org>
Mon, 18 Sep 2023 18:57:22 +0000 (08:57 -1000)
There is no check for possible failure while populating
cgroup1_base_files cft in css_populate_dir(), like its cgroup v2 counter
parts cgroup_{base,psi}_files.  In case of failure, the cgroup might not
be set up right.  Add ret value check to return on failure.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c

index 1fb7f562289d53263491738a6ea1e689933ab27f..d40d58b963c85230427eda4e43a52a317dca123a 100644 (file)
@@ -1731,8 +1731,10 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
                                        return ret;
                        }
                } else {
-                       cgroup_addrm_files(css, cgrp,
-                                          cgroup1_base_files, true);
+                       ret = cgroup_addrm_files(css, cgrp,
+                                                cgroup1_base_files, true);
+                       if (ret < 0)
+                               return ret;
                }
        } else {
                list_for_each_entry(cfts, &css->ss->cfts, node) {