Skip to contentSkip to conversation

init: Replace simple_strtoul with kstrtoul to improve lpj_setup

PATCH Superseded Thorsten Blum 1 participant 1 message Sep 15, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: Replace simple_strtoul with kstrtoul to improve lpj_setup

Replace simple_strtoul() with the recommended kstrtoul() for parsing the 'lpj=' boot parameter.

Check the return value of kstrtoul() and reject invalid values. This adds error handling while preserving existing behavior for valid values, and removes use of the deprecated simple_strtoul() helper.

---
 init/calibrate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
init/calibrate.c +2 -2
index f3831272f113..09c2e6102110 100644
@@ -14,10 +14,10 @@
 
 unsigned long lpj_fine;
 unsigned long preset_lpj;
+
 static int __init lpj_setup(char *str)
 {
-	preset_lpj = simple_strtoul(str,NULL,0);
-	return 1;
+	return kstrtoul(str, 0, &preset_lpj) == 0;
 }
 
 __setup("lpj=", lpj_setup);
Signature · 1 line
2.51.0