kallsyms: fix potential overflow in binary search
authorVegard Nossum <vegard.nossum@gmail.com>
Fri, 25 Jul 2008 08:45:34 +0000 (01:45 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 25 Jul 2008 17:53:27 +0000 (10:53 -0700)
This will probably never trigger... but it won't hurt to be careful.

http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html

Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Joshua Bloch <jjb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/kallsyms.c

index 6fc0040f3e3abacade62c7d63f74d240974d80fe..38fc10ac75415a8ff4da69b68d90facf61eb5e41 100644 (file)
@@ -176,7 +176,7 @@ static unsigned long get_symbol_pos(unsigned long addr,
        high = kallsyms_num_syms;
 
        while (high - low > 1) {
-               mid = (low + high) / 2;
+               mid = low + (high - low) / 2;
                if (kallsyms_addresses[mid] <= addr)
                        low = mid;
                else