[PATCH v4 3/4] selftests/mm: use pkey_assert on clone_raw failure in pkey test

From: Hongfu Li

Date: Fri May 29 2026 - 03:17:52 EST


Use pkey_assert(0) instead of perror("clone") when clone_raw() fails.
The old path only printed an error and continued; the test now exits
via pkey_assert() on failure so it does not hang or proceed with an
invalid child.

Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>
---
tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c
index 80b5b3dad86f..231dfb079075 100644
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
+++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -333,7 +333,7 @@ static void test_sigsegv_handler_with_different_pkey_for_stack(void)

if (child_pid < 0) {
errno = -child_pid;
- perror("clone");
+ pkey_assert(0);
} else if (child_pid == 0) {
thread_segv_maperr_ptr(&sigstack);
syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0);
@@ -500,7 +500,7 @@ static void test_pkru_sigreturn(void)

if (child_pid < 0) {
errno = -child_pid;
- perror("clone");
+ pkey_assert(0);
} else if (child_pid == 0) {
thread_sigusr2_self(&sigstack);
syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0);
--
2.50.1