rtc: Fix overflow when converting time64_t to rtc_time
authorBaolin Wang <baolin.wang@linaro.org>
Mon, 25 Dec 2017 11:10:37 +0000 (19:10 +0800)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 13 Feb 2018 20:30:28 +0000 (21:30 +0100)
commit36d46cdb43efea74043e29e2a62b13e9aca31452
treeb7b9dcfd8cb8805f3d2163cccbd2a96ec70c5d05
parent29a1f599c0cc37004f92ba455d1ccda3db0b6a94
rtc: Fix overflow when converting time64_t to rtc_time

If we convert one large time values to rtc_time, in the original formula
'days * 86400' can be overflowed in 'unsigned int' type to make the formula
get one incorrect remain seconds value. Thus we can use div_s64_rem()
function to avoid this situation.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-lib.c