]> www.infradead.org Git - users/jedix/linux-maple.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Mar 2019 05:13:55 +0000 (14:13 +0900)
commitc492471db905b6c7c673ae5630dd0a27c8cd00b0
tree0770e43f74736b627dc766c522464fb96b427254
parent421abdcc909322d6595504cf8d20c1adf74bc1cd
rtc: Fix overflow when converting time64_t to rtc_time

commit 36d46cdb43efea74043e29e2a62b13e9aca31452 upstream.

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>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/rtc/rtc-lib.c