[PATCH] Differentiate scenarios when watchdog is closed
From: Charles Haithcock
Date: Mon Aug 24 2026 - 16:55:51 EST
Presenty, when a watchdog device is closed, we print "watchdog did not
stop" in a few different scenarios;
1. When nowayout is set
2. When the watchdog is able to close, has received the magic character
to stop, but fails to close in device-specific code paths
3. When userspace delierately closes it without stopping it
For 1, we explicitly print we can not close because of nowayout. Nothing
differentiates the other two however.
This change adds a print to indicate the watchdog was closed while still
running.
Signed-off-by: Charles Haithcock <chaithco@xxxxxxxxxx>
---
drivers/watchdog/watchdog_dev.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index d7895009a2..a571dea353 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -955,14 +955,17 @@ static int watchdog_release(struct inode *inode, struct file *file)
if (!watchdog_active(wdd))
err = 0;
else if (test_and_clear_bit(_WDOG_ALLOW_RELEASE, &wd_data->status) ||
- !(wdd->info->options & WDIOF_MAGICCLOSE))
+ !(wdd->info->options & WDIOF_MAGICCLOSE)) {
err = watchdog_stop(wdd);
- /* If the watchdog was not stopped, send a keepalive ping */
- if (err < 0) {
- pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id);
- watchdog_ping(wdd);
+ /* If the watchdog was not stopped, send a keepalive ping */
+ if (err < 0) {
+ pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id);
+ watchdog_ping(wdd);
+ }
}
+ else
+ pr_info("watchdog%d: closing while running!\n", wdd->id);
watchdog_update_worker(wdd);
--
2.55.0