lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-10-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:12:29 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 009/437] lib/string_helpers: split __parse_int_array() into a helper

No functional changes, just in preparation for providing an iter based
version.

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 lib/string_helpers.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 69ba49b853c7..77f942809556 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -138,29 +138,11 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
 }
 EXPORT_SYMBOL(string_get_size);
 
-/**
- * parse_int_array_user - Split string into a sequence of integers
- * @from:	The user space buffer to read from
- * @count:	The maximum number of bytes to read
- * @array:	Returned pointer to sequence of integers
- *
- * On success @array is allocated and initialized with a sequence of
- * integers extracted from the @from plus an additional element that
- * begins the sequence and specifies the integers count.
- *
- * Caller takes responsibility for freeing @array when it is no longer
- * needed.
- */
-int parse_int_array_user(const char __user *from, size_t count, int **array)
+static int __parse_int_array(char *buf, int **array)
 {
 	int *ints, nints;
-	char *buf;
 	int ret = 0;
 
-	buf = memdup_user_nul(from, count);
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
-
 	get_options(buf, 0, &nints);
 	if (!nints) {
 		ret = -ENOENT;
@@ -180,6 +162,30 @@ int parse_int_array_user(const char __user *from, size_t count, int **array)
 	kfree(buf);
 	return ret;
 }
+
+/**
+ * parse_int_array_user - Split string into a sequence of integers
+ * @from:	The user space buffer to read from
+ * @count:	The maximum number of bytes to read
+ * @array:	Returned pointer to sequence of integers
+ *
+ * On success @array is allocated and initialized with a sequence of
+ * integers extracted from the @from plus an additional element that
+ * begins the sequence and specifies the integers count.
+ *
+ * Caller takes responsibility for freeing @array when it is no longer
+ * needed.
+ */
+int parse_int_array_user(const char __user *from, size_t count, int **array)
+{
+	char *buf;
+
+	buf = memdup_user_nul(from, count);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	return __parse_int_array(buf, array);
+}
 EXPORT_SYMBOL(parse_int_array_user);
 
 static bool unescape_space(char **src, char **dst)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ