[PATCH 3/6] watchdog: npcm: Enable clock before checking running state in probe

From: Lee Jones

Date: Thu Dec 03 2026 - 12:31:14 EST


npcm_wdt_probe() obtains the watchdog clock via
devm_clk_get_optional_prepared() and immediately calls
npcm_is_running(), reading the watchdog register before clk_enable() has
been invoked. On platforms with a gated peripheral clock, this causes
an unclocked MMIO access during probe.

Enable the clock before calling npcm_is_running(), start the watchdog
via __npcm_wdt_start() if it is already running (disabling the clock
otherwise), and disable the clock on subsequent probe error paths if it
was left enabled.

Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided")
Closes: https://sashiko.dev/#/bug/linux-119dbba3-5231-4944-9d7e-e954378626c9
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/watchdog/npcm_wdt.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index df7f66e77965..7a05673da4fc 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -448,24 +448,35 @@ static int npcm_wdt_probe(struct platform_device *pdev)

npcm_get_reset_status(wdt, dev, data, start);

+ ret = clk_enable(wdt->clk);
+ if (ret)
+ return ret;
+
if (npcm_is_running(&wdt->wdd)) {
/* Restart with the default or device-tree specified timeout */
- npcm_wdt_start(&wdt->wdd);
+ __npcm_wdt_start(&wdt->wdd);
set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
+ } else {
+ clk_disable(wdt->clk);
}

ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0, "watchdog",
wdt);
if (ret)
- return ret;
+ goto err_disable_clk;

ret = devm_watchdog_register_device(dev, &wdt->wdd);
if (ret)
- return ret;
+ goto err_disable_clk;

dev_info(dev, "NPCM watchdog driver enabled\n");

return 0;
+
+err_disable_clk:
+ if (watchdog_hw_running(&wdt->wdd))
+ clk_disable(wdt->clk);
+ return ret;
}

#ifdef CONFIG_OF
--
2.56.1.911.g883d8bcb20-goog