mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
powerpc: Remove broken GregorianDay()
GregorianDay() is supposed to calculate the day of the week (tm->tm_wday) for a given day/month/year. In that calcuation it indexed into an array called MonthOffset using tm->tm_mon-1. However tm_mon is zero-based, not one-based, so this is off-by-one. It also means that every January, GregoiranDay() will access element -1 of the MonthOffset array. It also doesn't appear to be a correct algorithm either: see in contrast kernel/time/timeconv.c's time_to_tm function. It's been broken forever, which suggests no-one in userland uses this. It looks like no-one in the kernel uses tm->tm_wday either (see e.g. drivers/rtc/rtc-ds1305.c:319). tm->tm_wday is conventionally set to -1 when not available in hardware so we can simply set it to -1 and drop the function. (There are over a dozen other drivers in drivers/rtc that do this.) Found using UBSAN. Cc: Andrey Ryabinin <[email protected]> Cc: Andrew Morton <[email protected]> # as an example of what UBSan finds. Cc: Alessandro Zummo <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: [email protected] Signed-off-by: Daniel Axtens <[email protected]> Acked-by: Alexandre Belloni <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
This commit is contained in:
parent
5f337e3e5b
commit
00b912b0c8
5 changed files with 5 additions and 39 deletions
|
|
@ -40,7 +40,7 @@ static void opal_to_tm(u32 y_m_d, u64 h_m_s_ms, struct rtc_time *tm)
|
|||
tm->tm_min = bcd2bin((h_m_s_ms >> 48) & 0xff);
|
||||
tm->tm_sec = bcd2bin((h_m_s_ms >> 40) & 0xff);
|
||||
|
||||
GregorianDay(tm);
|
||||
tm->tm_wday = -1;
|
||||
}
|
||||
|
||||
static void tm_to_opal(struct rtc_time *tm, u32 *y_m_d, u64 *h_m_s_ms)
|
||||
|
|
|
|||
Loading…
Reference in a new issue