Re: [tip:timers/core] ntp: Add ADJ_SETOFFSET mode bit

From: Richard Cochran
Date: Fri Feb 18 2011 - 04:08:20 EST



I just noticed a problem with this code. As is, the code will not
detect if the microseconds field (the non-ADJ_NANO case) is out of
range. However, the call to timekeeping_inject_offset() would silently
fail.

This patch corrects the problem by letting timekeeping_inject_offset()
do the check and catching the return code.

Author: Richard Cochran <richard.cochran@xxxxxxxxxx>
Date: Fri Feb 18 09:54:19 2011 +0100

ntp: remove useless and incorrect parameter check

The ADJ_SETOFFSET code redundantly checks the range of the nanoseconds
field of the time value. This field is checked again in the subsequent
call to timekeeping_inject_offset(). Also, as is, the check will not
detect whether the number of microseconds is out of range.

This patch simply lets timekeeping_inject_offset() do the error checking.

Signed-off-by: Richard Cochran <richard.cochran@xxxxxxxxxx>

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 34d1b64..d62f35a 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -648,13 +648,13 @@ int do_adjtimex(struct timex *txc)

if (txc->modes & ADJ_SETOFFSET) {
struct timespec delta;
- if ((unsigned long)txc->time.tv_usec >= NSEC_PER_SEC)
- return -EINVAL;
delta.tv_sec = txc->time.tv_sec;
delta.tv_nsec = txc->time.tv_usec;
if (!(txc->modes & ADJ_NANO))
delta.tv_nsec *= 1000;
- timekeeping_inject_offset(&delta);
+ result = timekeeping_inject_offset(&delta);
+ if (result)
+ return result;
}

getnstimeofday(&ts);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/