From a4c9190649738c061ad309142053876b6f709aa3 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 24 Mar 2020 16:09:24 -0700 Subject: [PATCH] kernel: fix oops policy for k_thread_abort() Don't generate a Z_OOPS() if k_thread_abort() is called on a thread that isn't running. Just return to the caller instead, much like how k_thread_join() functions. Signed-off-by: Andrew Boie --- kernel/sched.c | 15 ++++++++++++++- kernel/thread.c | 11 ----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/kernel/sched.c b/kernel/sched.c index 25bbb9463f0..66b760373ef 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1472,7 +1472,7 @@ static bool thread_obj_validate(struct k_thread *thread) CODE_UNREACHABLE; } -int z_vrfy_k_thread_join(struct k_thread *thread, s32_t timeout) +static inline int z_vrfy_k_thread_join(struct k_thread *thread, s32_t timeout) { if (thread_obj_validate(thread)) { return 0; @@ -1481,4 +1481,17 @@ int z_vrfy_k_thread_join(struct k_thread *thread, s32_t timeout) return z_impl_k_thread_join(thread, timeout); } #include + +static inline void z_vrfy_k_thread_abort(k_tid_t thread) +{ + if (thread_obj_validate(thread)) { + return; + } + + Z_OOPS(Z_SYSCALL_VERIFY_MSG(!(thread->base.user_options & K_ESSENTIAL), + "aborting essential thread %p", thread)); + + z_impl_k_thread_abort((struct k_thread *)thread); +} +#include #endif /* CONFIG_USERSPACE */ diff --git a/kernel/thread.c b/kernel/thread.c index ce14b20a1c7..fc8af5767ff 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -843,17 +843,6 @@ static inline int z_vrfy_k_float_disable(struct k_thread *thread) return z_impl_k_float_disable(thread); } #include - -static inline void z_vrfy_k_thread_abort(k_tid_t thread) -{ - Z_OOPS(Z_SYSCALL_OBJ(thread, K_OBJ_THREAD)); - Z_OOPS(Z_SYSCALL_VERIFY_MSG(!(thread->base.user_options & K_ESSENTIAL), - "aborting essential thread %p", thread)); - - z_impl_k_thread_abort((struct k_thread *)thread); -} -#include - #endif /* CONFIG_USERSPACE */ #ifdef CONFIG_IRQ_OFFLOAD