From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-watchdog@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 6/6] watchdog: rzv2h: Avoid 32-bit overflow in max_hw_heartbeat_ms calculation
Date: Thu, 3 Dec 2026 17:30:09 +0000 [thread overview]
Message-ID: <20261203173039.1142495-7-lee@kernel.org> (raw)
In-Reply-To: <20261203173039.1142495-1-lee@kernel.org>
For RZ/T2H SoCs, MILLI * timeout_cycles * cks_div equals 33,554,432,000,
which overflows 32-bit unsigned long on 32-bit builds.
Perform the multiplication in 64-bit arithmetic and divide using
div64_ul().
Fixes: 2b2069763527 ("watchdog: rzv2h: Add support for RZ/T2H")
Closes: https://sashiko.dev/#/bug/linux-441577c6-bf0c-46ed-bc43-676afdcc85bf
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/watchdog/rzv2h_wdt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/watchdog/rzv2h_wdt.c b/drivers/watchdog/rzv2h_wdt.c
index 67869468edd8..81bf6a36b139 100644
--- a/drivers/watchdog/rzv2h_wdt.c
+++ b/drivers/watchdog/rzv2h_wdt.c
@@ -8,6 +8,7 @@
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/kernel.h>
+#include <linux/math64.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
@@ -310,8 +311,9 @@ static int rzv2h_wdt_probe(struct platform_device *pdev)
if (!rate)
return dev_err_probe(dev, -EINVAL, "Invalid clock rate\n");
- priv->wdev.max_hw_heartbeat_ms = (MILLI * priv->of_data->timeout_cycles *
- priv->of_data->cks_div) / rate;
+ priv->wdev.max_hw_heartbeat_ms =
+ div64_ul((u64)MILLI * priv->of_data->timeout_cycles *
+ priv->of_data->cks_div, rate);
dev_dbg(dev, "max hw timeout of %dms\n", priv->wdev.max_hw_heartbeat_ms);
ret = devm_pm_runtime_enable(dev);
--
2.56.1.911.g883d8bcb20-goog
prev parent reply other threads:[~2026-12-03 17:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:30 [PATCH 0/6] watchdog: Fix High issues reported by Sashiko Lee Jones
2026-12-03 17:30 ` [PATCH 1/6] watchdog: da9063: Stop ping worker on system suspend Lee Jones
2026-12-03 18:31 ` sashiko-bot
2026-12-03 17:30 ` [PATCH 2/6] watchdog: dw_wdt: Guard shared IRQ handler during system suspend and resume Lee Jones
2026-12-03 17:30 ` [PATCH 3/6] watchdog: npcm: Enable clock before checking running state in probe Lee Jones
2026-12-03 17:30 ` [PATCH 4/6] watchdog: sbsa: Evaluate MediaTek WS0 workaround after IRQ fallback Lee Jones
2026-12-03 17:30 ` [PATCH 5/6] watchdog: octeon-wdt: Serialise countdown and IRQ state with raw spinlock Lee Jones
2026-12-03 17:30 ` Lee Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203173039.1142495-7-lee@kernel.org \
--to=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=wim@linux-watchdog.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox