aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Williams <pwil3058@bigpond.net.au>2006-02-03 06:04:33 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-03 11:32:08 -0500
commitf0c00257d63463fa9d692e632fae037d6c0e67b0 (patch)
tree94ca16b28d70eb96155974909560cced8a3cf383
parent6bf8d889ed453f709dedacabdcf5db47470fdae9 (diff)
[PATCH] lib: Fix bug in int_sqrt() for 64 bit longs
The implementation of int_sqrt() assumes that longs have 32 bits. On systems that have 64 bit longs this will result in gross errors when the argument to the function is greater than 2^32 - 1 on such systems. I doubt whether any such use is currently made of int_sqrt() but the attached patch fixes the problem anyway. Signed-off-by: Peter Williams <pwil3058@bigpond.com.au> Cc: Dave Jones <davej@codemonkey.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--lib/int_sqrt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c
index a5d2cdc5684c..fd355a99327c 100644
--- a/lib/int_sqrt.c
+++ b/lib/int_sqrt.c
@@ -15,7 +15,7 @@ unsigned long int_sqrt(unsigned long x)
15 op = x; 15 op = x;
16 res = 0; 16 res = 0;
17 17
18 one = 1 << 30; 18 one = 1UL << (BITS_PER_LONG - 2);
19 while (one > op) 19 while (one > op)
20 one >>= 2; 20 one >>= 2;
21 21