summaryrefslogtreecommitdiffstats
path: root/lib/kunit
diff options
context:
space:
mode:
authorMickaël Salaün <mic@digikod.net>2024-04-08 09:46:19 +0200
committerShuah Khan <skhan@linuxfoundation.org>2024-05-06 14:22:02 -0600
commitcde5e1b4a90486b4ac731ee43e4e0152cc16887b (patch)
tree6a1af2e8867f29e57a82a0b9e2217dd093884e21 /lib/kunit
parentdd5a440a31fae6e459c0d6271dddd62825505361 (diff)
downloadlinux-stable-cde5e1b4a90486b4ac731ee43e4e0152cc16887b.tar.gz
linux-stable-cde5e1b4a90486b4ac731ee43e4e0152cc16887b.tar.bz2
linux-stable-cde5e1b4a90486b4ac731ee43e4e0152cc16887b.zip
kunit: Handle thread creation error
Previously, if a thread creation failed (e.g. -ENOMEM), the function was called (kunit_catch_run_case or kunit_catch_run_case_cleanup) without marking the test as failed. Instead, fill try_result with the error code returned by kthread_run(), which will mark the test as failed and print "internal error occurred...". Cc: Brendan Higgins <brendanhiggins@google.com> Cc: Shuah Khan <skhan@linuxfoundation.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Rae Moar <rmoar@google.com> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Mickaël Salaün <mic@digikod.net> Link: https://lore.kernel.org/r/20240408074625.65017-2-mic@digikod.net Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit')
-rw-r--r--lib/kunit/try-catch.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/kunit/try-catch.c b/lib/kunit/try-catch.c
index f7825991d576..a5cb2ef70a25 100644
--- a/lib/kunit/try-catch.c
+++ b/lib/kunit/try-catch.c
@@ -69,6 +69,7 @@ void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)
try_catch,
"kunit_try_catch_thread");
if (IS_ERR(task_struct)) {
+ try_catch->try_result = PTR_ERR(task_struct);
try_catch->catch(try_catch->context);
return;
}