]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
init: replace simple_strtoul with kstrtoul to improve lpj_setup
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 22 Nov 2025 11:45:37 +0000 (12:45 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 27 Nov 2025 22:24:43 +0000 (14:24 -0800)
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.

Link: https://lkml.kernel.org/r/20251122114539.446937-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
init/calibrate.c

index f3831272f11357205a02faed344dc65aa244ce38..09c2e61021105e0241020a992a853c1e1328f920 100644 (file)
 
 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);