Commit 5f82b2b7 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds

[PATCH] hrtimer: create and use timespec_valid macro

add timespec_valid(ts) [returns false if the timespec is denorm]
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2a698971
...@@ -44,6 +44,12 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, ...@@ -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); 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 xtime;
extern struct timespec wall_to_monotonic; extern struct timespec wall_to_monotonic;
extern seqlock_t xtime_lock; extern seqlock_t xtime_lock;
......
...@@ -712,8 +712,7 @@ out: ...@@ -712,8 +712,7 @@ out:
*/ */
static int good_timespec(const struct timespec *ts) static int good_timespec(const struct timespec *ts)
{ {
if ((!ts) || (ts->tv_sec < 0) || if ((!ts) || !timespec_valid(ts))
((unsigned) ts->tv_nsec >= NSEC_PER_SEC))
return 0; return 0;
return 1; return 1;
} }
...@@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t which_clock, int flags, ...@@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t which_clock, int flags,
if (copy_from_user(&t, rqtp, sizeof (struct timespec))) if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
return -EFAULT; return -EFAULT;
if ((unsigned) t.tv_nsec >= NSEC_PER_SEC || t.tv_sec < 0) if (!timespec_valid(&t))
return -EINVAL; return -EINVAL;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment