03 Sep, 2008

1 commit

  • commit 945185a69daa457c4c5e46e47f4afad7dcea734f ("rtc: rtc_time_to_tm: use
    unsigned arithmetic") changed the some types in rtc_time_to_tm() to
    unsigned:

    void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
    {
    - register int days, month, year;
    + unsigned int days, month, year;

    This doesn't work for all cases, because days is checked for < 0 later
    on:

    if (days < 0) {
    year -= 1;
    days += 365 + LEAP_YEAR(year);
    }

    I think the correct fix would be to keep days signed and do an appropriate
    cast later on.

    Signed-off-by: Jan Altenberg
    Cc: Maciej W. Rozycki
    Cc: Alessandro Zummo
    Cc: David Brownell
    Cc: Dmitri Vorobiev
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Altenberg
     

13 May, 2008

1 commit

  • The input argument to rtc_time_to_tm() is unsigned as well as are members of
    the output structure. However signed arithmetic is used within for
    calculations leading to incorrect results for input values outside the signed
    positive range. If this happens the time of day returned is out of range.

    Found the problem when fiddling with the RTC and the driver where year was set
    to an unexpectedly large value like 2070, e.g.:

    rtc0: setting system clock to 2070-01-01 1193046:71582832:26 UTC (3155760954)

    while it should be:

    rtc0: setting system clock to 2070-01-01 00:15:54 UTC (3155760954)

    Changing types to unsigned fixes the problem.

    [akpm@linux-foundation.org: remove old-fashioned `register' keyword]
    Signed-off-by: Maciej W. Rozycki
    Cc: Alessandro Zummo
    Cc: David Brownell
    Cc: Dmitri Vorobiev
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Maciej W. Rozycki
     

09 May, 2007

1 commit

  • David says "884b4aaaa242a2db8c8252796f0118164a680ab5 should be reverted. It
    added an rtc_merge_alarm() call to the 2.6.20 kernel, which hasn't yet been
    used by any in-tree driver; this patch obviates the need for that call, and
    uses a more robust approach."

    Cc: Scott Wood
    Cc: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

11 Dec, 2006

1 commit

  • Add rtc_merge_alarm(), which can be used by rtc drivers to turn a partially
    specified alarm expiry (i.e. most significant fields set to -1, as with the
    RTC_ALM_SET ioctl()) into a fully specified expiry.

    If the most significant specified field is earlier than the current time, the
    least significant unspecified field is incremented.

    Signed-off-by: Scott Wood
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Scott Wood
     

01 Oct, 2006

1 commit

  • The rtc_is_valid_tm() routine needs to treat some of the fields it checks as
    unsigned, to prevent wrongly accepting invalid rtc_time structs; this is the
    same approach used elsewhere in the RTC code for such tests.

    Conversely, rtc_proc_show() is missing one invalid-day-of-month test that
    rtc_is_valid_tm() makes: there is no day zero.

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

26 Jun, 2006

1 commit


28 Mar, 2006

1 commit