All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] watchdog: rzg2l_wdt: Fix 32bit overflow issue
@ 2021-12-13 15:26 Biju Das
  2021-12-13 15:26 ` [PATCH v2 2/4] watchdog: rzg2l_wdt: Add error check for reset_control_{deassert/reset} Biju Das
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Biju Das @ 2021-12-13 15:26 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: Biju Das, linux-watchdog, Geert Uytterhoeven, Chris Paterson,
	Biju Das, Prabhakar Mahadev Lad, linux-renesas-soc

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.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
V1->V2:
 * Added Rb tag from Guenter and Geert.
---
 drivers/watchdog/rzg2l_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 6b426df34fd6..96f2a018ab62 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -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);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-04 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 15:26 [PATCH v2 1/4] watchdog: rzg2l_wdt: Fix 32bit overflow issue Biju Das
2021-12-13 15:26 ` [PATCH v2 2/4] watchdog: rzg2l_wdt: Add error check for reset_control_{deassert/reset} Biju Das
2022-01-04 16:36   ` Biju Das
2021-12-13 15:26 ` [PATCH v2 3/4] watchdog: rzg2l_wdt: Add set_timeout callback Biju Das
2021-12-13 15:26 ` [PATCH v2 4/4] watchdog: rzg2l_wdt: Use force reset for WDT reset Biju Das
2022-01-04 16:38   ` Biju Das

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.