From 31f3e2ad8e581a202c520e6b33a97ee56770a877 Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Sun, 19 Jan 2003 06:51:10 +0000 Subject: [PATCH] useracc() is mpsafe so we only need to hold Giant over the call to nanosleep1() Pointed out by: tjr --- sys/kern/kern_time.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 2d53d3fb892d..aaa389054c23 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -293,24 +293,19 @@ nanosleep(struct thread *td, struct nanosleep_args *uap) if (error) return (error); + if (uap->rmtp && + !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) + return (EFAULT); mtx_lock(&Giant); - if (uap->rmtp) { - if (!useracc((caddr_t)uap->rmtp, sizeof(rmt), - VM_PROT_WRITE)) { - error = EFAULT; - goto done2; - } - } error = nanosleep1(td, &rqt, &rmt); + mtx_unlock(&Giant); if (error && uap->rmtp) { int error2; error2 = copyout(&rmt, uap->rmtp, sizeof(rmt)); - if (error2) /* XXX shouldn't happen, did useracc() above */ + if (error2) error = error2; } -done2: - mtx_unlock(&Giant); return (error); }