diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2012-02-28 12:42:14 +0000 | 
|---|---|---|
| committer | Arnd Bergmann <arnd@arndb.de> | 2012-02-28 12:42:21 +0000 | 
| commit | fb0b82b32ce17564bc64cede50bf4a3204eecc60 (patch) | |
| tree | 00b5e466074c6fb373d64c493b3341186024acc7 /lib/kstrtox.c | |
| parent | a173fc693b25216c5c834978f4fafd731fd4ff94 (diff) | |
| parent | 43de6a7dda6e9a7345e218e688f2092f991126f0 (diff) | |
Merge branch 'board-specific' of git://github.com/hzhuang1/linux into next/boards
* 'board-specific' of git://github.com/hzhuang1/linux: (5 commits)
  ARM: pxa: add dummy clock for pxa25x and pxa27x
  ARM: mmp: append irq name of gpio device
  pxa/hx4700: Fix PXA_GPIO_IRQ_BASE/IRQ_NUM values
  pxa/hx4700: Add ASIC3 LED support
  pxa/hx4700: Correct StrataFlash block size discovery
(update to v3.3-rc5)
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)   *   * Don't you dare use this function.   */ -unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res) +unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)  { +	unsigned long long res;  	unsigned int rv;  	int overflow; -	*res = 0; +	res = 0;  	rv = 0;  	overflow = 0;  	while (*s) { @@ -64,12 +65,19 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long  		if (val >= base)  			break; -		if (*res > div_u64(ULLONG_MAX - val, base)) -			overflow = 1; -		*res = *res * base + val; +		/* +		 * Check for overflow only if we are within range of +		 * it in the max base we support (16) +		 */ +		if (unlikely(res & (~0ull << 60))) { +			if (res > div_u64(ULLONG_MAX - val, base)) +				overflow = 1; +		} +		res = res * base + val;  		rv++;  		s++;  	} +	*p = res;  	if (overflow)  		rv |= KSTRTOX_OVERFLOW;  	return rv; | 
