diff options
author | davidxu <davidxu@FreeBSD.org> | 2003-07-07 04:28:23 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2003-07-07 04:28:23 +0000 |
commit | 8aa4e2d6856d1eed699b30ccca6163f8e501e183 (patch) | |
tree | 6539674ba4c0ff3018faf64006ac81eb9090ec5f /lib/libpthread/thread/thr_getschedparam.c | |
parent | e95dd66c1f7fd662d47b34b5d83f1dcaa8b150e3 (diff) | |
download | FreeBSD-src-8aa4e2d6856d1eed699b30ccca6163f8e501e183.zip FreeBSD-src-8aa4e2d6856d1eed699b30ccca6163f8e501e183.tar.gz |
Avoid accessing user provided parameters in critical region.
Reviewed by: deischen
Diffstat (limited to 'lib/libpthread/thread/thr_getschedparam.c')
-rw-r--r-- | lib/libpthread/thread/thr_getschedparam.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libpthread/thread/thr_getschedparam.c b/lib/libpthread/thread/thr_getschedparam.c index d00e498..ad8486c 100644 --- a/lib/libpthread/thread/thr_getschedparam.c +++ b/lib/libpthread/thread/thr_getschedparam.c @@ -42,7 +42,7 @@ _pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) { struct pthread *curthread = _get_curthread(); - int ret; + int ret, tmp; if ((param == NULL) || (policy == NULL)) /* Return an invalid argument error: */ @@ -55,8 +55,9 @@ _pthread_getschedparam(pthread_t pthread, int *policy, THR_SCHED_LOCK(curthread, curthread); param->sched_priority = THR_BASE_PRIORITY(pthread->base_priority); - *policy = pthread->attr.sched_policy; + tmp = pthread->attr.sched_policy; THR_SCHED_UNLOCK(curthread, curthread); + *policy = tmp; ret = 0; } /* Find the thread in the list of active threads. */ @@ -65,9 +66,10 @@ _pthread_getschedparam(pthread_t pthread, int *policy, THR_SCHED_LOCK(curthread, pthread); param->sched_priority = THR_BASE_PRIORITY(pthread->base_priority); - *policy = pthread->attr.sched_policy; + tmp = pthread->attr.sched_policy; THR_SCHED_UNLOCK(curthread, pthread); _thr_ref_delete(curthread, pthread); + *policy = tmp; } return (ret); } |