Commit fd4615c9 authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds

[PATCH] ia64 extable sorting fix

Fix a goofup from the recent sort consolidation patches.

- Subtractions in comparison functions could overflow the return type for
  64-bit pointers.  Make it right again.

- Add missing size arg to ia64 extable swap function.
Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f1af5aff
......@@ -17,10 +17,15 @@ static int cmp_ex(const void *a, const void *b)
u64 lip = (u64) &l->addr + l->addr;
u64 rip = (u64) &r->addr + r->addr;
return lip - rip;
/* avoid overflow */
if (lip > rip)
return 1;
if (lip < rip)
return -1;
return 0;
}
static void swap_ex(void *a, void *b)
static void swap_ex(void *a, void *b, int size)
{
struct exception_table_entry *l = a, *r = b, tmp;
u64 delta = (u64) r - (u64) l;
......
......@@ -29,7 +29,13 @@ extern struct exception_table_entry __stop___ex_table[];
static int cmp_ex(const void *a, const void *b)
{
const struct exception_table_entry *x = a, *y = b;
return x->insn - y->insn;
/* avoid overflow */
if (x->insn > y->insn)
return 1;
if (x->insn < y->insn)
return -1;
return 0;
}
void sort_extable(struct exception_table_entry *start,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment