* [PATCH] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup
@ 2025-09-18 16:24 Thorsten Blum
2025-09-24 13:35 ` Jan Kara
2025-09-29 9:04 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-09-18 16:24 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: Thorsten Blum, linux-fsdevel, linux-kernel
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>
---
init/do_mounts_rd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index ac021ae6e6fa..79d5375ad712 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -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);
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup
2025-09-18 16:24 [PATCH] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup Thorsten Blum
@ 2025-09-24 13:35 ` Jan Kara
2025-09-29 9:04 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2025-09-24 13:35 UTC (permalink / raw)
To: Thorsten Blum
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel, linux-kernel
On Thu 18-09-25 18:24:47, Thorsten Blum wrote:
> 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>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> init/do_mounts_rd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
> index ac021ae6e6fa..79d5375ad712 100644
> --- a/init/do_mounts_rd.c
> +++ b/init/do_mounts_rd.c
> @@ -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);
>
> --
> 2.51.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup
2025-09-18 16:24 [PATCH] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup Thorsten Blum
2025-09-24 13:35 ` Jan Kara
@ 2025-09-29 9:04 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-09-29 9:04 UTC (permalink / raw)
To: Thorsten Blum
Cc: Christian Brauner, linux-fsdevel, linux-kernel, Alexander Viro, Jan Kara
On Thu, 18 Sep 2025 18:24:47 +0200, Thorsten Blum wrote:
> 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.
>
> [...]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-29 9:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 16:24 [PATCH] initrd: Replace simple_strtol with kstrtoint to improve ramdisk_start_setup Thorsten Blum
2025-09-24 13:35 ` Jan Kara
2025-09-29 9:04 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®