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 <ycsin@meta.com>
This commit is contained in:
Yong Cong Sin 2023-10-04 11:11:24 +08:00 committed by Fabio Baltieri
parent 38470a4231
commit 0cd135920a

View File

@ -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);