1. 03 9月, 2008 1 次提交
    • J
      rtc_time_to_tm: fix signed/unsigned arithmetic · 73442daf
      Jan Altenberg 提交于
      commit 945185a6 ("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: NJan Altenberg <jan.altenberg@linutronix.de>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      73442daf
  2. 13 5月, 2008 1 次提交
    • M
      rtc: rtc_time_to_tm: use unsigned arithmetic · 945185a6
      Maciej W. Rozycki 提交于
      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: NMaciej W. Rozycki <macro@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      945185a6
  3. 09 5月, 2007 1 次提交
  4. 11 12月, 2006 1 次提交
  5. 01 10月, 2006 1 次提交
  6. 26 6月, 2006 1 次提交
  7. 28 3月, 2006 1 次提交