Re: [PATCH] rtc: tps6594: Fix integer overflow on 32bit systems

From: Alexandre Belloni
Date: Sun Jan 12 2025 - 18:21:40 EST


On Wed, 11 Dec 2024 12:32:34 +0300, Dan Carpenter wrote:
> The problem is this multiply in tps6594_rtc_set_offset()
>
> tmp = offset * TICKS_PER_HOUR;
>
> The "tmp" variable is an s64 but "offset" is a long in the
> (-277774)-277774 range. On 32bit systems a long can hold numbers up to
> approximately two billion. The number of TICKS_PER_HOUR is really large,
> (32768 * 3600) or roughly a hundred million. When you start multiplying
> by a hundred million it doesn't take long to overflow the two billion
> mark.
>
> [...]

Applied, thanks!

[1/1] rtc: tps6594: Fix integer overflow on 32bit systems
https://git.kernel.org/abelloni/c/09c4a6101532

Best regards,

--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com