diff options
| author | Ingo Molnar <mingo@kernel.org> | 2012-10-24 10:20:57 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2012-10-24 10:20:57 +0200 |
| commit | ef8c029fa793423439e67ef0416b220d3fa3321a (patch) | |
| tree | 4199cefa6e1dcad1783040755246a14371f029af /lib/parser.c | |
| parent | 6fcdb1ed2ef3548d5a9428d6ae60158ddd46a608 (diff) | |
| parent | c13d38e4a1fd5dd07135403c613c8091af444169 (diff) | |
Merge branch 'perf/urgent' into perf/core
Pick up v3.7-rc2 and fixes before applying more patches.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib/parser.c')
| -rw-r--r-- | lib/parser.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/parser.c b/lib/parser.c index c43410084838..52cfa69f73df 100644 --- a/lib/parser.c +++ b/lib/parser.c @@ -122,13 +122,14 @@ int match_token(char *s, const match_table_t table, substring_t args[]) * * Description: Given a &substring_t and a base, attempts to parse the substring * as a number in that base. On success, sets @result to the integer represented - * by the string and returns 0. Returns either -ENOMEM or -EINVAL on failure. + * by the string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure. */ static int match_number(substring_t *s, int *result, int base) { char *endp; char *buf; int ret; + long val; size_t len = s->to - s->from; buf = kmalloc(len + 1, GFP_KERNEL); @@ -136,10 +137,15 @@ static int match_number(substring_t *s, int *result, int base) return -ENOMEM; memcpy(buf, s->from, len); buf[len] = '\0'; - *result = simple_strtol(buf, &endp, base); + ret = 0; + val = simple_strtol(buf, &endp, base); if (endp == buf) ret = -EINVAL; + else if (val < (long)INT_MIN || val > (long)INT_MAX) + ret = -ERANGE; + else + *result = (int) val; kfree(buf); return ret; } |
