summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-10-30 15:05:26 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-31 08:54:12 -0700
commit4ed97b3c6d088e063e065142fc3217fae5cc29f8 (patch)
tree348cc3bdcfecfbf9bdf2b81f6ea1e63b57c072c7
parent30f7bc99a2a97cce9cda17d411c748550c0ece7b (diff)
downloadlinux-4ed97b3c6d088e063e065142fc3217fae5cc29f8.tar.gz
lib/parser.c: switch match_u64int() over to use match_strdup()
This simplifies the code.  No change in behavior.

Link: http://lkml.kernel.org/r/20180830194814.192880-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--lib/parser.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/parser.c b/lib/parser.c
index 0142ef28f0eb..618c36ec8efe 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -166,13 +166,10 @@ static int match_u64int(substring_t *s, u64 *result, int base)
 	char *buf;
 	int ret;
 	u64 val;
-	size_t len = s->to - s->from;
 
-	buf = kmalloc(len + 1, GFP_KERNEL);
+	buf = match_strdup(s);
 	if (!buf)
 		return -ENOMEM;
-	memcpy(buf, s->from, len);
-	buf[len] = '\0';
 
 	ret = kstrtoull(buf, base, &val);
 	if (!ret)