Add missing pthread_create() return checks in pkey sighandler tests
to avoid hanging in pthread_cond_wait() when thread creation fails.

Signed-off-by: Hongfu Li <[email protected]>
Acked-by: Mike Rapoport (Microsoft) <[email protected]>
Acked-by: Liam R. Howlett (Oracle) <[email protected]>
Reviewed-by: Kevin Brodsky <[email protected]>
Tested-by: Kevin Brodsky <[email protected]>
---
 tools/testing/selftests/mm/pkey_sighandler_tests.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c 
b/tools/testing/selftests/mm/pkey_sighandler_tests.c
index 8f98e6d9349f..cbc24d6cf770 100644
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
+++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -220,7 +220,11 @@ static void test_sigsegv_handler_with_pkey0_disabled(void)
        pthread_attr_init(&attr);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
-       pthread_create(&thr, &attr, thread_segv_with_pkey0_disabled, NULL);
+       ret = pthread_create(&thr, &attr, thread_segv_with_pkey0_disabled, 
NULL);
+       if (ret) {
+               errno = ret;
+               pkey_assert(0);
+       }
 
        pthread_mutex_lock(&mutex);
        while (siginfo.si_signo == 0)
@@ -259,7 +263,11 @@ static void test_sigsegv_handler_cannot_access_stack(void)
        pthread_attr_init(&attr);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
-       pthread_create(&thr, &attr, thread_segv_pkuerr_stack, NULL);
+       ret = pthread_create(&thr, &attr, thread_segv_pkuerr_stack, NULL);
+       if (ret) {
+               errno = ret;
+               pkey_assert(0);
+       }
 
        pthread_mutex_lock(&mutex);
        while (siginfo.si_signo == 0)
-- 
2.25.1


Reply via email to