[PATCH] watchdog: restart handler: hang when watchdog cannot restart the machine

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 5 03:52:26 PST 2024


The __builtin_unreachable() in watchdog_restart_handle() is bogus,
because when the watchdog doesn't work we will run into
__builtin_unreachable() and behaviour is undefined. Drop the call
to __builtin_unreachable(), print a big fat warning and hang() the
machine which makes sure we don't return from watchdog_restart_handle().

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/watchdog/wd_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 89e4f1d1ea..f39a8f4522 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -179,7 +179,9 @@ static void __noreturn watchdog_restart_handle(struct restart_handler *this)
 
 	BUG_ON(ret);
 	mdelay(2000);
-	__builtin_unreachable();
+
+	pr_emerg("Watchdog failed to reset the machine\n");
+	hang();
 }
 
 static struct restart_handler restart_handler = {
-- 
2.39.2




More information about the barebox mailing list