aboutsummaryrefslogtreecommitdiffstats
path: root/lib/parser.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-10-30 18:05:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-31 11:54:12 -0400
commit36c8d1e7a27f94b4d812b2a0abf106dab0fa377e (patch)
treea66e60a5e0c9093d49e7b0d7c27e4f7e696163b7 /lib/parser.c
parent4ed97b3c6d088e063e065142fc3217fae5cc29f8 (diff)
lib/parser.c: switch match_number() over to use match_strdup()
This simplifies the code. No change in behavior. Link: http://lkml.kernel.org/r/20180830194727.191555-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>
Diffstat (limited to 'lib/parser.c')
-rw-r--r--lib/parser.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/parser.c b/lib/parser.c
index 618c36ec8efe..dd70e5e6c9e2 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -131,13 +131,10 @@ static int match_number(substring_t *s, int *result, int base)
131 char *buf; 131 char *buf;
132 int ret; 132 int ret;
133 long val; 133 long val;
134 size_t len = s->to - s->from;
135 134
136 buf = kmalloc(len + 1, GFP_KERNEL); 135 buf = match_strdup(s);
137 if (!buf) 136 if (!buf)
138 return -ENOMEM; 137 return -ENOMEM;
139 memcpy(buf, s->from, len);
140 buf[len] = '\0';
141 138
142 ret = 0; 139 ret = 0;
143 val = simple_strtol(buf, &endp, base); 140 val = simple_strtol(buf, &endp, base);