[LTP] [PATCH] cgroup_fj: Check start_path before removing directories in cleanup
Wake Liu
wakel@google.com
Fri Aug 28 14:02:42 CEST 2026
When setup() fails early (for example, when a cgroup controller is not
available and cgroup_require triggers TCONF), start_path has not yet
been assigned.
In this case, cleanup() in cgroup_fj_function.sh unconditionally runs
rmdir "$start_path/ltp_1", which evaluates to rmdir /ltp_1 and fails.
Similarly, common_cleanup() prints a message about removing all ltp
subgroups even when none were created.
Add checks to verify that start_path is non-empty and the directory
exists before attempting removal.
Signed-off-by: Wake Liu <wakel@google.com>
---
testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh | 7 ++++---
.../kernel/controllers/cgroup_fj/cgroup_fj_function.sh | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
index 8b5e73466..03e416f55 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
@@ -79,9 +79,10 @@ common_cleanup()
{
killall -9 cgroup_fj_proc >/dev/null 2>&1
- tst_res TINFO "Removing all ltp subgroups..."
-
- [ -d "$start_path" ] && find "$start_path" -depth -type d -exec rmdir '{}' \;
+ if [ -n "$start_path" ] && [ -d "$start_path" ]; then
+ tst_res TINFO "Removing all ltp subgroups..."
+ find "$start_path" -depth -type d -exec rmdir '{}' \;
+ fi
cgroup_cleanup
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
index b0c9410ca..61b7a0415 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
@@ -231,7 +231,7 @@ cleanup()
wait $pid >/dev/null 2>&1
fi
- rmdir "$start_path/ltp_1" >/dev/null 2>&1
+ [ -n "$start_path" ] && [ -d "$start_path/ltp_1" ] && rmdir "$start_path/ltp_1" >/dev/null 2>&1
common_cleanup
}
--
2.55.0.897.gb25b4bd76c-goog
More information about the ltp
mailing list