lkml.org 
[lkml]   [2011]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [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@omicron.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@omicron.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);

    \
     
     \ /
      Last update: 2011-02-18 10:11    [W:2.551 / U:0.232 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site