Skip to content

Commit

Permalink
watchdog: rzg2l_wdt: Fix 32bit overflow issue
Browse files Browse the repository at this point in the history
[ Upstream commit ea2949d ]

The value of timer_cycle_us can be 0 due to 32bit overflow.
For eg:- If we assign the counter value "0xfff" for computing
maxval.

This patch fixes this issue by appending ULL to 1024, so that
it is promoted to 64bit.

This patch also fixes the warning message, 'watchdog: Invalid min and
max timeout values, resetting to 0!'.

Fixes: 2cbc5cd ("watchdog: Add Watchdog Timer driver for RZ/G2L")
Signed-off-by: Biju Das <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Wim Van Sebroeck <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Biju Das authored and Sasha Levin committed Jun 13, 2022
1 parent f3d443b commit 55166bb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/watchdog/rzg2l_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void rzg2l_wdt_wait_delay(struct rzg2l_wdt_priv *priv)

static u32 rzg2l_wdt_get_cycle_usec(unsigned long cycle, u32 wdttime)
{
u64 timer_cycle_us = 1024 * 1024 * (wdttime + 1) * MICRO;
u64 timer_cycle_us = 1024 * 1024ULL * (wdttime + 1) * MICRO;

return div64_ul(timer_cycle_us, cycle);
}
Expand Down

0 comments on commit 55166bb

Please sign in to comment.