From c166685fcfeb9a11157c8d5aba8b2806df2aaf7c Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Thu, 19 Oct 2023 22:27:15 -0700 Subject: [PATCH] ztest: Do not abort k_current_get from ISR Do not abort k_current_get() from ISR. Signed-off-by: Flavio Ceolin --- subsys/testsuite/ztest/src/ztest.c | 5 ++++- subsys/testsuite/ztest/src/ztest_new.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index 4215ec77c89..12271e61eb9 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -439,8 +439,11 @@ static void test_finalize(void) { if (IS_ENABLED(CONFIG_MULTITHREADING)) { k_thread_abort(&ztest_thread); - k_thread_abort(k_current_get()); + if (k_is_in_isr()) { + return; + } + k_thread_abort(k_current_get()); CODE_UNREACHABLE; } } diff --git a/subsys/testsuite/ztest/src/ztest_new.c b/subsys/testsuite/ztest/src/ztest_new.c index 4215ec77c89..12271e61eb9 100644 --- a/subsys/testsuite/ztest/src/ztest_new.c +++ b/subsys/testsuite/ztest/src/ztest_new.c @@ -439,8 +439,11 @@ static void test_finalize(void) { if (IS_ENABLED(CONFIG_MULTITHREADING)) { k_thread_abort(&ztest_thread); - k_thread_abort(k_current_get()); + if (k_is_in_isr()) { + return; + } + k_thread_abort(k_current_get()); CODE_UNREACHABLE; } }