summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGrant Slater <github@firefishy.com>2026-01-16 14:38:48 +0000
committerGrant Slater <github@firefishy.com>2026-01-16 15:34:50 +0000
commit94d27bc0331d2595f9fd98c9477507806f4dd0d0 (patch)
treee1ebec70d91c24dca519db8b245a55d02d3e45b8 /src
parent3f3e9d2e9d62eba72e3f82b2e88cae31d75afa37 (diff)
downloadvyos-1x-94d27bc0331d2595f9fd98c9477507806f4dd0d0.tar.gz
vyos-1x-94d27bc0331d2595f9fd98c9477507806f4dd0d0.zip
T8187: fix watchdog timeout validation if kernel min/max timeout are zero
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/system_watchdog.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/conf_mode/system_watchdog.py b/src/conf_mode/system_watchdog.py
index 059e74dd9..8c050f333 100755
--- a/src/conf_mode/system_watchdog.py
+++ b/src/conf_mode/system_watchdog.py
@@ -63,7 +63,7 @@ def _read_sysfs_int(path: Path) -> Optional[int]:
def _get_watchdog_timeout_limits() -> tuple[int, int]:
"""Return (min_timeout, max_timeout) from sysfs if available.
- If sysfs is unavailable (device not present/loaded yet), fall back to a
+ If sysfs is unavailable (device not present/loaded yet) or zero, fall back to a
conservative common kernel max of 65535 seconds.
"""
@@ -74,10 +74,8 @@ def _get_watchdog_timeout_limits() -> tuple[int, int]:
max_timeout = _read_sysfs_int(WATCHDOG_SYSFS / 'max_timeout')
# Some drivers may not expose min/max. Fall back to sane defaults.
- if min_timeout is None:
- min_timeout = 1
- if max_timeout is None:
- max_timeout = 65535
+ min_timeout = min_timeout if min_timeout and min_timeout > 0 else 1
+ max_timeout = max_timeout if max_timeout and max_timeout > 0 else 65535
return min_timeout, max_timeout