summaryrefslogtreecommitdiffstats
path: root/kernel/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/compat.c')
-rw-r--r--kernel/compat.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index 38b1d2c1cbe..06cbb061953 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -893,7 +893,7 @@ compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese,
int sig;
struct timespec t;
siginfo_t info;
- long ret, timeout = 0;
+ long ret, timeout;
if (sigsetsize != sizeof(sigset_t))
return -EINVAL;
@@ -904,36 +904,30 @@ compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese,
sigdelsetmask(&s,sigmask(SIGKILL)|sigmask(SIGSTOP));
signotset(&s);
+ timeout = MAX_SCHEDULE_TIMEOUT;
if (uts) {
if (get_compat_timespec (&t, uts))
return -EFAULT;
- if (t.tv_nsec >= 1000000000L || t.tv_nsec < 0
- || t.tv_sec < 0)
+ if (!timespec_valid(&t))
return -EINVAL;
+ timeout = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
}
spin_lock_irq(&current->sighand->siglock);
sig = dequeue_signal(current, &s, &info);
- if (!sig) {
- timeout = MAX_SCHEDULE_TIMEOUT;
- if (uts)
- timeout = timespec_to_jiffies(&t)
- +(t.tv_sec || t.tv_nsec);
- if (timeout) {
- current->real_blocked = current->blocked;
- sigandsets(&current->blocked, &current->blocked, &s);
-
- recalc_sigpending();
- spin_unlock_irq(&current->sighand->siglock);
-
- timeout = schedule_timeout_interruptible(timeout);
-
- spin_lock_irq(&current->sighand->siglock);
- sig = dequeue_signal(current, &s, &info);
- current->blocked = current->real_blocked;
- siginitset(&current->real_blocked, 0);
- recalc_sigpending();
- }
+ if (!sig && timeout) {
+ current->real_blocked = current->blocked;
+ sigandsets(&current->blocked, &current->blocked, &s);
+ recalc_sigpending();
+ spin_unlock_irq(&current->sighand->siglock);
+
+ timeout = schedule_timeout_interruptible(timeout);
+
+ spin_lock_irq(&current->sighand->siglock);
+ sig = dequeue_signal(current, &s, &info);
+ current->blocked = current->real_blocked;
+ siginitset(&current->real_blocked, 0);
+ recalc_sigpending();
}
spin_unlock_irq(&current->sighand->siglock);
@@ -943,7 +937,7 @@ compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese,
if (copy_siginfo_to_user32(uinfo, &info))
ret = -EFAULT;
}
- }else {
+ } else {
ret = timeout?-EINTR:-EAGAIN;
}
return ret;