From: Wayen Yan <win847@gmail.com>
To: Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: Guenter Roeck <linux@roeck-us.net>,
Christian Marangi <ansuelsmth@gmail.com>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] watchdog: airoha: validate heartbeat module parameter
Date: Wed, 8 Jul 2026 13:24:37 +0800 [thread overview]
Message-ID: <178348833669.86438.10575372757097263872@gmail.com> (raw)
The probe function directly assigns the heartbeat module parameter to
wdog_dev->timeout without any validation. If heartbeat exceeds
max_timeout, the product timeout * wdt_freq (computed in
airoha_wdt_start()) can overflow the 32-bit WDT_TIMER_LOAD_VALUE
register, causing the watchdog to expire immediately and reboot the
system.
Fix by using watchdog_init_timeout() which validates the timeout
against [min_timeout, max_timeout] range, and falls back to the
device tree "timeout-sec" property if the module parameter is invalid.
Fixes: 3cf67f3769b8 ("watchdog: Add support for Airoha EN7851 watchdog")
Signed-off-by: Wayen Yan <win847@gmail.com>
---
drivers/watchdog/airoha_wdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/watchdog/airoha_wdt.c b/drivers/watchdog/airoha_wdt.c
index dc8ca11c14d8..67160d760d84 100644
--- a/drivers/watchdog/airoha_wdt.c
+++ b/drivers/watchdog/airoha_wdt.c
@@ -150,13 +150,13 @@ static int airoha_wdt_probe(struct platform_device *pdev)
/* Initialize struct watchdog device */
wdog_dev = &airoha_wdt->wdog_dev;
- wdog_dev->timeout = heartbeat;
wdog_dev->info = &airoha_wdt_info;
wdog_dev->ops = &airoha_wdt_ops;
/* Bus 300MHz, watchdog 150MHz, 28 seconds */
wdog_dev->max_timeout = FIELD_MAX(WDT_TIMER_VAL) / airoha_wdt->wdt_freq;
wdog_dev->parent = dev;
+ watchdog_init_timeout(wdog_dev, heartbeat, dev);
watchdog_set_drvdata(wdog_dev, airoha_wdt);
watchdog_set_nowayout(wdog_dev, nowayout);
watchdog_stop_on_unregister(wdog_dev);
--
2.51.0
next reply other threads:[~2026-07-08 5:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 5:24 Wayen Yan [this message]
2026-07-08 5:36 ` [PATCH] watchdog: airoha: validate heartbeat module parameter sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-07-08 5:55 Wayen Yan
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=178348833669.86438.10575372757097263872@gmail.com \
--to=win847@gmail.com \
--cc=ansuelsmth@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wim@linux-watchdog.org \
/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