kernel: mutex: Copy assertions to assertions to syscall handler

Always ensure that the mutex owner is the current thread and that the
count is sane.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
Leandro Pereira 2018-04-05 09:25:01 -07:00 committed by Andrew Boie
parent 361ef34043
commit bf44bacd24

View file

@ -256,5 +256,12 @@ void _impl_k_mutex_unlock(struct k_mutex *mutex)
}
#ifdef CONFIG_USERSPACE
_SYSCALL_HANDLER1_SIMPLE_VOID(k_mutex_unlock, K_OBJ_MUTEX, struct k_mutex *);
_SYSCALL_HANDLER(k_mutex_unlock, mutex)
{
_SYSCALL_OBJ(mutex, K_OBJ_MUTEX);
_SYSCALL_VERIFY(((struct k_mutex *)mutex)->lock_count > 0);
_SYSCALL_VERIFY(((struct k_mutex *)mutex)->owner == _current);
_impl_k_mutex_unlock((struct k_mutex *)mutex);
return 0;
}
#endif