diff options
| author | Mark Brown <broonie@kernel.org> | 2016-11-04 14:16:38 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2016-11-04 14:16:38 -0400 |
| commit | cc9b94029e9ef51787af908e9856b1eed314bc00 (patch) | |
| tree | 9675310b89d0f6fb1f7bd9423f0638c4ee5226fd /lib/kstrtox.c | |
| parent | 13bed58ce8748d430a26e353a09b89f9d613a71f (diff) | |
| parent | 1b5b42216469b05ef4b5916cb40b127dfab1da88 (diff) | |
Merge branch 'topic/error' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-fixed
Diffstat (limited to 'lib/kstrtox.c')
| -rw-r--r-- | lib/kstrtox.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index d8a5cf66c316..b8e2080c1a47 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
| @@ -48,11 +48,9 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long | |||
| 48 | { | 48 | { |
| 49 | unsigned long long res; | 49 | unsigned long long res; |
| 50 | unsigned int rv; | 50 | unsigned int rv; |
| 51 | int overflow; | ||
| 52 | 51 | ||
| 53 | res = 0; | 52 | res = 0; |
| 54 | rv = 0; | 53 | rv = 0; |
| 55 | overflow = 0; | ||
| 56 | while (*s) { | 54 | while (*s) { |
| 57 | unsigned int val; | 55 | unsigned int val; |
| 58 | 56 | ||
| @@ -71,15 +69,13 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long | |||
| 71 | */ | 69 | */ |
| 72 | if (unlikely(res & (~0ull << 60))) { | 70 | if (unlikely(res & (~0ull << 60))) { |
| 73 | if (res > div_u64(ULLONG_MAX - val, base)) | 71 | if (res > div_u64(ULLONG_MAX - val, base)) |
| 74 | overflow = 1; | 72 | rv |= KSTRTOX_OVERFLOW; |
| 75 | } | 73 | } |
| 76 | res = res * base + val; | 74 | res = res * base + val; |
| 77 | rv++; | 75 | rv++; |
| 78 | s++; | 76 | s++; |
| 79 | } | 77 | } |
| 80 | *p = res; | 78 | *p = res; |
| 81 | if (overflow) | ||
| 82 | rv |= KSTRTOX_OVERFLOW; | ||
| 83 | return rv; | 79 | return rv; |
| 84 | } | 80 | } |
| 85 | 81 | ||
