Skip to content

Commit

Permalink
kernel: avoid overflow in cmp_range
Browse files Browse the repository at this point in the history
Avoid overflow possibility.

[ The overflow is purely theoretical, since this is used for memory
  ranges that aren't even close to using the full 64 bits, but this is
  the right thing to do regardless.  - Linus ]

Signed-off-by: Louis Langholtz <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Peter Anvin <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
louis-langholtz authored and torvalds committed Jan 16, 2015
1 parent 7ad4b4a commit fc7f0dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kernel/range.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ static int cmp_range(const void *x1, const void *x2)
{
const struct range *r1 = x1;
const struct range *r2 = x2;
s64 start1, start2;

start1 = r1->start;
start2 = r2->start;

return start1 - start2;
if (r1->start < r2->start)
return -1;
if (r1->start > r2->start)
return 1;
return 0;
}

int clean_sort_range(struct range *range, int az)
Expand Down

0 comments on commit fc7f0dd

Please sign in to comment.