linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/block/loop: Remove deprecated function, range check for max_loop
@ 2019-06-25 11:40 Florian Knauf
  2019-06-25 15:42 ` Chaitanya Kulkarni
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Knauf @ 2019-06-25 11:40 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-kernel, linux-block, linux-kernel, Florian Knauf, Christian Ewert

This patch removes the deprecated simple_strtol function from the option
parsing logic in the loopback device driver. It also introduces a range
check for the max_loop parameter to ensure that negative and out-of-range
values (that cannot be represented by int max_loop) are ignored.

Signed-off-by: Florian Knauf <florian.knauf@stud.uni-hannover.de>
Signed-off-by: Christian Ewert <christian.ewert@stud.uni-hannover.de>
---
 drivers/block/loop.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 102d79575895..acdd028ed486 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2289,7 +2289,17 @@ module_exit(loop_exit);
 #ifndef MODULE
 static int __init max_loop_setup(char *str)
 {
-	max_loop = simple_strtol(str, NULL, 0);
+	long max_loop_long = 0;
+
+	/*
+	 * Range check for max_loop: negative values and values not
+	 * representable by int are ignored.
+	 */
+	if (kstrtol(str, 0, &max_loop_long) == 0 &&
+			max_loop_long >= 0 &&
+			max_loop_long <= INT_MAX)
+		max_loop = (int) max_loop_long;
+
 	return 1;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-02  5:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 11:40 [PATCH] drivers/block/loop: Remove deprecated function, range check for max_loop Florian Knauf
2019-06-25 15:42 ` Chaitanya Kulkarni
2019-06-25 17:55   ` [PATCH v2] drivers/block/loop: Replace deprecated function in option parsing code Florian Knauf
2019-06-25 19:24     ` Chaitanya Kulkarni
2019-06-29 19:46       ` Florian Knauf
2019-07-02  5:04         ` Chaitanya Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).