From 90f5852369c1fc6e74ff7f4a61f4d0f423ef00d2 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Mon, 9 Jan 2006 20:52:29 -0800 Subject: [PATCH] --- yaml --- r: 17587 b: refs/heads/master c: 5f82b2b77e66d452c3037cc47f436d2d76fd5f06 h: refs/heads/master i: 17585: 00eeffd4024a95c9defdaa379ec04fcf2a8614d6 17583: deec2d8109ca9d9826bb836a10e7e6860a21f75d v: v3 --- [refs] | 2 +- trunk/include/linux/time.h | 6 ++++++ trunk/kernel/posix-timers.c | 5 ++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index dd1c2d625d6c..0e08f77cd540 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2a698971941bf5e6ebe96275f7d5318b2cf91ccf +refs/heads/master: 5f82b2b77e66d452c3037cc47f436d2d76fd5f06 diff --git a/trunk/include/linux/time.h b/trunk/include/linux/time.h index 4d49cabb9b47..64e797464589 100644 --- a/trunk/include/linux/time.h +++ b/trunk/include/linux/time.h @@ -44,6 +44,12 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); +/* + * Returns true if the timespec is norm, false if denorm: + */ +#define timespec_valid(ts) \ + (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) + extern struct timespec xtime; extern struct timespec wall_to_monotonic; extern seqlock_t xtime_lock; diff --git a/trunk/kernel/posix-timers.c b/trunk/kernel/posix-timers.c index 69d5a4b5395b..6b851a1bf4b0 100644 --- a/trunk/kernel/posix-timers.c +++ b/trunk/kernel/posix-timers.c @@ -712,8 +712,7 @@ sys_timer_create(const clockid_t which_clock, */ static int good_timespec(const struct timespec *ts) { - if ((!ts) || (ts->tv_sec < 0) || - ((unsigned) ts->tv_nsec >= NSEC_PER_SEC)) + if ((!ts) || !timespec_valid(ts)) return 0; return 1; } @@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t which_clock, int flags, if (copy_from_user(&t, rqtp, sizeof (struct timespec))) return -EFAULT; - if ((unsigned) t.tv_nsec >= NSEC_PER_SEC || t.tv_sec < 0) + if (!timespec_valid(&t)) return -EINVAL; /*