]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
watchdog: iTCO_wdt: Report error if timeout configuration fails
authorZiyan Fu <fuzy5@lenovo.com>
Fri, 4 Jul 2025 07:35:18 +0000 (15:35 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:59 +0000 (16:25 +0200)
commitadb142fcacb849b6108aa752159357da1d4ade7d
treeee07379a9e6e1a3dba4b091ad64c2791deac65e9
parent4c207015fcb8b91929cbe78486920f7575a3d848
watchdog: iTCO_wdt: Report error if timeout configuration fails

[ Upstream commit 40efc43eb7ffb5a4e2f998c13b8cfb555e671b92 ]

The driver probes with the invalid timeout value when
'iTCO_wdt_set_timeout()' fails, as its return value is not checked. In
this case, when executing "wdctl", we may get:

Device:        /dev/watchdog0
Timeout:       30 seconds
Timeleft:      613 seconds

The timeout value is the value of "heartbeat" or "WATCHDOG_TIMEOUT", and
the timeleft value is calculated from the register value we actually read
(0xffff) by masking with 0x3ff and converting ticks to seconds (* 6 / 10).

Add error handling to return the failure code if 'iTCO_wdt_set_timeout()'
fails, ensuring the driver probe fails and prevents invalid operation.

Signed-off-by: Ziyan Fu <fuzy5@lenovo.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20250704073518.7838-1-13281011316@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/watchdog/iTCO_wdt.c