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

Configure Feed

Select the types of activity you want to include in your feed.

brd: replace simple_strtol with kstrtoul in ramdisk_size

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

Check the return value of kstrtoul() and reject invalid values. This
adds error handling while preserving behavior for existing values, and
removes use of the deprecated simple_strtol() helper. The current code
silently sets 'rd_size = 0' if parsing fails, instead of leaving the
default value (CONFIG_BLK_DEV_RAM_SIZE) unchanged.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Thorsten Blum and committed by
Jens Axboe
e1418af7 4cef2fcd

+1 -2
+1 -2
drivers/block/brd.c
··· 247 247 /* Legacy boot options - nonmodular */ 248 248 static int __init ramdisk_size(char *str) 249 249 { 250 - rd_size = simple_strtol(str, NULL, 0); 251 - return 1; 250 + return kstrtoul(str, 0, &rd_size) == 0; 252 251 } 253 252 __setup("ramdisk_size=", ramdisk_size); 254 253 #endif