From 0cd135920a883c89437e9a754dc2a88f4cb39ee2 Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Wed, 4 Oct 2023 11:11:24 +0800 Subject: [PATCH] kernel: work: check handler when submit to queue Assert that the handler of a work is not NULL when submitting it to the queue. This allows early detection of the code that is submitting a non-NULL work with NULL handler to the work queue (where it happens), rather than right before the work item get executed in the queue (when it happens). Signed-off-by: Yong Cong Sin --- kernel/work.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/work.c b/kernel/work.c index 010cd732183..c5d7c9b5bb8 100644 --- a/kernel/work.c +++ b/kernel/work.c @@ -370,6 +370,7 @@ int z_work_submit_to_queue(struct k_work_q *queue, struct k_work *work) { __ASSERT_NO_MSG(work != NULL); + __ASSERT_NO_MSG(work->handler != NULL); k_spinlock_key_t key = k_spin_lock(&lock);