Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup

Replace simple_strtol() with the recommended kstrtoint() for parsing the
'ramdisk_start=' boot parameter. Unlike simple_strtol(), which returns a
a long, kstrtoint() converts the string directly to an integer and
avoids implicit casting.

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

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Thorsten Blum and committed by
Christian Brauner
b2c43efc 3a866087

+1 -2
+1 -2
init/do_mounts_rd.c
··· 29 29 30 30 static int __init ramdisk_start_setup(char *str) 31 31 { 32 - rd_image_start = simple_strtol(str,NULL,0); 33 - return 1; 32 + return kstrtoint(str, 0, &rd_image_start) == 0; 34 33 } 35 34 __setup("ramdisk_start=", ramdisk_start_setup); 36 35