From df6acfd7c436d98725e8dab37393e51f4f394496 Mon Sep 17 00:00:00 2001 From: davidxu Date: Wed, 29 Sep 2010 06:06:58 +0000 Subject: [PATCH] Check invalid mutex in _mutex_cv_unlock. --- lib/libthr/thread/thr_mutex.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 12ff1df8d4cf..a83454a0e3f4 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -636,6 +636,12 @@ _mutex_cv_unlock(pthread_mutex_t *mutex, int *count) struct pthread_mutex *m; m = *mutex; + if (__predict_false(m <= THR_MUTEX_DESTROYED)) { + if (m == THR_MUTEX_DESTROYED) + return (EINVAL); + return (EPERM); + } + /* * Check if the running thread is not the owner of the mutex. */