[PATCH -next] block: Replaced simple_strtol() with kstrtoint()/kstrtoul()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The simple_strtol() function is deprecated in some situation since
it does not check for the range overflow. Use kstrtoint()/kstrtoul()
instead.
Attention, if the end of the input string isn't '\n', simple_strtol() will
ignore following characters and return the value but kstrtoint()/kstrtoul()
will return an error code.

Signed-off-by: Liu Shixin <liushixin2@xxxxxxxxxx>
---
 drivers/block/brd.c  | 3 +--
 drivers/block/loop.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 7562cf30b14e..5b43f6b2d506 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -358,8 +358,7 @@ MODULE_ALIAS("rd");
 /* Legacy boot options - nonmodular */
 static int __init ramdisk_size(char *str)
 {
-	rd_size = simple_strtol(str, NULL, 0);
-	return 1;
+	return !kstrtoul(str, 0, &rd_size);
 }
 __setup("ramdisk_size=", ramdisk_size);
 #endif
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d58d68f3c7cd..9fe595afa9cf 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2415,8 +2415,7 @@ module_exit(loop_exit);
 #ifndef MODULE
 static int __init max_loop_setup(char *str)
 {
-	max_loop = simple_strtol(str, NULL, 0);
-	return 1;
+	return !kstrtoint(str, 0, &max_loop);
 }
 
 __setup("max_loop=", max_loop_setup);
-- 
2.18.0.huawei.25




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux