From 8aa4e2d6856d1eed699b30ccca6163f8e501e183 Mon Sep 17 00:00:00 2001 From: davidxu Date: Mon, 7 Jul 2003 04:28:23 +0000 Subject: Avoid accessing user provided parameters in critical region. Reviewed by: deischen --- lib/libpthread/thread/thr_mutex_prioceiling.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/libpthread/thread/thr_mutex_prioceiling.c') diff --git a/lib/libpthread/thread/thr_mutex_prioceiling.c b/lib/libpthread/thread/thr_mutex_prioceiling.c index a78b5d1..c65270a 100644 --- a/lib/libpthread/thread/thr_mutex_prioceiling.c +++ b/lib/libpthread/thread/thr_mutex_prioceiling.c @@ -93,6 +93,7 @@ _pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling) { int ret = 0; + int tmp; if ((mutex == NULL) || (*mutex == NULL)) ret = EINVAL; @@ -100,12 +101,15 @@ _pthread_mutex_setprioceiling(pthread_mutex_t *mutex, ret = EINVAL; /* Lock the mutex: */ else if ((ret = pthread_mutex_lock(mutex)) == 0) { - /* Return the old ceiling and set the new ceiling: */ - *old_ceiling = (*mutex)->m_prio; + tmp = (*mutex)->m_prio; + /* Set the new ceiling: */ (*mutex)->m_prio = prioceiling; /* Unlock the mutex: */ ret = pthread_mutex_unlock(mutex); + + /* Return the old ceiling: */ + *old_ceiling = tmp; } return(ret); } -- cgit v1.1