Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 17587
b: refs/heads/master
c: 5f82b2b
h: refs/heads/master
i:
  17585: 00eeffd
  17583: deec2d8
v: v3
  • Loading branch information
Thomas Gleixner authored and Linus Torvalds committed Jan 10, 2006
1 parent b1213a5 commit 90f5852
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2a698971941bf5e6ebe96275f7d5318b2cf91ccf
refs/heads/master: 5f82b2b77e66d452c3037cc47f436d2d76fd5f06
6 changes: 6 additions & 0 deletions trunk/include/linux/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions trunk/kernel/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

/*
Expand Down

0 comments on commit 90f5852

Please sign in to comment.