]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/cgroup: fix child process escaping to parent cleanup in test_cpucg_nice
authorTao Cui <cuitao@kylinos.cn>
Mon, 11 May 2026 06:15:08 +0000 (14:15 +0800)
committerTejun Heo <tj@kernel.org>
Mon, 11 May 2026 08:29:06 +0000 (22:29 -1000)
In test_cpucg_nice, the forked child process incorrectly jumps to the
parent's cleanup label on cg_write failure. This causes the child to
attempt cg_destroy on cgroups the parent is still using, and then
return to main() to continue executing tests as if it were the parent.

Replace goto cleanup with exit(EXIT_FAILURE) in the child process.

Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/testing/selftests/cgroup/test_cpu.c

index c83f05438d7ccadfb95f2d70dea37dcf2e903eb3..7a40d76b95487c5704f25de3a37d57118e544823 100644 (file)
@@ -278,7 +278,7 @@ static int test_cpucg_nice(const char *root)
                char buf[64];
                snprintf(buf, sizeof(buf), "%d", getpid());
                if (cg_write(cpucg, "cgroup.procs", buf))
-                       goto cleanup;
+                       exit(EXIT_FAILURE);
 
                /* Try to keep niced CPU usage as constrained to hog_cpu as possible */
                nice(1);