initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup
PATCH 1/1 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.
--- init/do_mounts_rd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
init/do_mounts_rd.c +1 -2
@@ -28,8 +28,7 @@ int __initdata rd_image_start; /* starting block # of image */static int __init ramdisk_start_setup (char *str) { - rd_image_start =simple_strtol (str,NULL ,0 ); -return 1 ; +return kstrtoint (str,0 , &rd_image_start) ==0 ; }__setup ("ramdisk_start=" , ramdisk_start_setup);
Signature · 1 line
2.51.0
Quoted 10 lines · Thorsten Blum
Replace
simple_strtol()with the recommendedkstrtoint()for parsing the 'ramdisk_start=' boot parameter. Unlikesimple_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 deprecatedsimple_strtol()helper.Signed-off-by Thorsten Blum <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 21 lines
--- init/do_mounts_rd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)init/do_mounts_rd.c +1
-2@@ -28,8 +28,7 @@ int __initdata rd_image_start; /* starting block # of image */static int __init ramdisk_start_setup (char *str) { - rd_image_start =simple_strtol (str,NULL ,0 ); -return 1 ; +return kstrtoint (str,0 , &rd_image_start) ==0 ; }__setup ("ramdisk_start=" , ramdisk_start_setup);Signature · 1 line
2.51.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 10 lines · Thorsten Blum
Replace
simple_strtol()with the recommendedkstrtoint()for parsing the 'ramdisk_start=' boot parameter. Unlikesimple_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 deprecatedsimple_strtol()helper.[...]
Applied to the vfs-6.19.misc branch of the vfs/vfs.git tree. Patches in the vfs-6.19.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-6.19.misc
[1/1] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup
https://git.kernel.org/vfs/vfs/c/17230195b76e