[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110218090724.GA2924@riccoc20.at.omicron.at>
Date: Fri, 18 Feb 2011 10:07:25 +0100
From: Richard Cochran <richardcochran@...il.com>
To: linux-kernel@...r.kernel.org
Cc: hpa@...or.com, mingo@...hat.com, johnstul@...ibm.com,
tglx@...utronix.de, richard.cochran@...cron.at
Subject: Re: [tip:timers/core] ntp: Add ADJ_SETOFFSET mode bit
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@...cron.at>
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@...cron.at>
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists