From 6f357b60ff5eba97316062347c457a49633f064e Mon Sep 17 00:00:00 2001 From: Dmitriy Korovkin Date: Fri, 4 Nov 2016 15:18:07 -0400 Subject: [PATCH] unified/kernel: Assert that mutex is not unlocked without previous locking Add an assertion against unlocking mutex that is not locked. Change-Id: I1032fb904e364015b486502c035529c8fe31de7a Signed-off-by: Dmitriy Korovkin --- kernel/unified/mutex.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/unified/mutex.c b/kernel/unified/mutex.c index be2c6154f3d..5e567ac74e7 100644 --- a/kernel/unified/mutex.c +++ b/kernel/unified/mutex.c @@ -214,6 +214,7 @@ void k_mutex_unlock(struct k_mutex *mutex) { int key; + __ASSERT(mutex->lock_count > 0, ""); __ASSERT(mutex->owner == _current, ""); k_sched_lock();