diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-19 12:41:24 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-19 12:41:24 -0400 |
commit | 9ce28d827f74d0acdd058bded8bab5309b0f5c8f (patch) | |
tree | 634f22e8df9c7fd3966b3639e3e997436751ca50 /lib/kstrtox.c | |
parent | f074ff92b5b26f3a559fab1203c36e140ea8d067 (diff) | |
parent | c16fa4f2ad19908a47c63d8fa436a1178438c7e7 (diff) |
Merge tag 'v3.3' into staging/for_v3.4
* tag 'v3.3': (1646 commits)
Linux 3.3
Don't limit non-nested epoll paths
netfilter: ctnetlink: fix race between delete and timeout expiration
ipv6: Don't dev_hold(dev) in ip6_mc_find_dev_rcu.
nilfs2: fix NULL pointer dereference in nilfs_load_super_block()
nilfs2: clamp ns_r_segments_percentage to [1, 99]
afs: Remote abort can cause BUG in rxrpc code
afs: Read of file returns EBADMSG
C6X: remove dead code from entry.S
wimax/i2400m: fix erroneous NETDEV_TX_BUSY use
net/hyperv: fix erroneous NETDEV_TX_BUSY use
net/usbnet: reserve headroom on rx skbs
bnx2x: fix memory leak in bnx2x_init_firmware()
bnx2x: fix a crash on corrupt firmware file
sch_sfq: revert dont put new flow at the end of flows
ipv6: fix icmp6_dst_alloc()
MAINTAINERS: Add Serge as maintainer of capabilities
drivers/video/backlight/s6e63m0.c: fix corruption storing gamma mode
MAINTAINERS: add entry for exynos mipi display drivers
MAINTAINERS: fix link to Gustavo Padovans tree
...
Diffstat (limited to 'lib/kstrtox.c')
-rw-r--r-- | lib/kstrtox.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index 7a94c8f14e29..b1dd3e7d88cb 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
@@ -44,12 +44,13 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base) | |||
44 | * | 44 | * |
45 | * Don't you dare use this function. | 45 | * Don't you dare use this function. |
46 | */ | 46 | */ |
47 | unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res) | 47 | unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p) |
48 | { | 48 | { |
49 | unsigned long long res; | ||
49 | unsigned int rv; | 50 | unsigned int rv; |
50 | int overflow; | 51 | int overflow; |
51 | 52 | ||
52 | *res = 0; | 53 | res = 0; |
53 | rv = 0; | 54 | rv = 0; |
54 | overflow = 0; | 55 | overflow = 0; |
55 | while (*s) { | 56 | while (*s) { |
@@ -64,12 +65,19 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long | |||
64 | 65 | ||
65 | if (val >= base) | 66 | if (val >= base) |
66 | break; | 67 | break; |
67 | if (*res > div_u64(ULLONG_MAX - val, base)) | 68 | /* |
68 | overflow = 1; | 69 | * Check for overflow only if we are within range of |
69 | *res = *res * base + val; | 70 | * it in the max base we support (16) |
71 | */ | ||
72 | if (unlikely(res & (~0ull << 60))) { | ||
73 | if (res > div_u64(ULLONG_MAX - val, base)) | ||
74 | overflow = 1; | ||
75 | } | ||
76 | res = res * base + val; | ||
70 | rv++; | 77 | rv++; |
71 | s++; | 78 | s++; |
72 | } | 79 | } |
80 | *p = res; | ||
73 | if (overflow) | 81 | if (overflow) |
74 | rv |= KSTRTOX_OVERFLOW; | 82 | rv |= KSTRTOX_OVERFLOW; |
75 | return rv; | 83 | return rv; |