From 6145949f883a180a46f9e2122bcc0acbc2b591a2 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 15 Feb 2021 06:01:01 +0100 Subject: [PATCH] core/mutex: Add assert guard against usage without threads --- core/mutex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/mutex.c b/core/mutex.c index cba168ee81..9bf8690e68 100644 --- a/core/mutex.c +++ b/core/mutex.c @@ -49,7 +49,9 @@ static inline __attribute__((always_inline)) void _block(mutex_t *mutex, unsigned irq_state) { thread_t *me = thread_get_active(); - + /* Fail visibly even if a blocking action is called from somewhere where + * it's subtly not allowed, eg. board_init */ + assert(me != NULL); DEBUG("PID[%" PRIkernel_pid "] mutex_lock() Adding node to mutex queue: " "prio: %" PRIu32 "\n", thread_getpid(), (uint32_t)me->priority); sched_set_status(me, STATUS_MUTEX_BLOCKED);