[PATCH v2 1/2] watchdog: use kstrtouint to parse softlockup_panic=
From: 林濬哲
Date: Tue Sep 22 2026 - 01:52:01 EST
simple_strtoul() is deprecated. Replace it with kstrtouint(). A bad
value now leaves the variable unchanged and produces a warning,
instead of being silently clamped.
__setup() handlers return whether they handled the option; there is
no way to propagate parse errors, so the handler simply returns 1.
v2: warn on a bad value and return 1 instead of returning the parse
error, which __setup() handlers cannot do (Guenter Roeck).
Signed-off-by: Lin Junzhe <m18667909625@xxxxxxx>
Assisted-by: AI coding assistant (disclosed per kernel AI guidelines)
---
kernel/watchdog.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index e5134ad7b663..7f8c904554a9 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -17,6 +17,7 @@
#include <linux/irq.h>
#include <linux/irqdesc.h>
#include <linux/kernel_stat.h>
+#include <linux/kstrtox.h>
#include <linux/kvm_para.h>
#include <linux/math64.h>
#include <linux/mm.h>
@@ -422,7 +423,11 @@ static unsigned long soft_lockup_nmi_warn;
static int __init softlockup_panic_setup(char *str)
{
- softlockup_panic = simple_strtoul(str, NULL, 0);
+ int ret;
+
+ ret = kstrtouint(str, 0, &softlockup_panic);
+ if (ret)
+ pr_warn("softlockup_panic: bad option string '%s'\n", str);
return 1;
}
__setup("softlockup_panic=", softlockup_panic_setup);
--
2.54.0.windows.1