diff options
author | Louis Langholtz <lou_langholtz@me.com> | 2015-01-16 00:04:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-16 16:02:23 -0500 |
commit | fc7f0dd381720ea5ee5818645f7d0e9dece41cb0 (patch) | |
tree | 704eb796bfcdf42f5d04a48fabc2ffd24c824be0 | |
parent | 7ad4b4ae5757b89637f5767ae5d9e1436a6413e0 (diff) |
kernel: avoid overflow in cmp_range
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 <lou_langholtz@me.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Peter Anvin <hpa@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/range.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kernel/range.c b/kernel/range.c index 322ea8e93e4b..82cfc285b046 100644 --- a/kernel/range.c +++ b/kernel/range.c | |||
@@ -113,12 +113,12 @@ static int cmp_range(const void *x1, const void *x2) | |||
113 | { | 113 | { |
114 | const struct range *r1 = x1; | 114 | const struct range *r1 = x1; |
115 | const struct range *r2 = x2; | 115 | const struct range *r2 = x2; |
116 | s64 start1, start2; | ||
117 | 116 | ||
118 | start1 = r1->start; | 117 | if (r1->start < r2->start) |
119 | start2 = r2->start; | 118 | return -1; |
120 | 119 | if (r1->start > r2->start) | |
121 | return start1 - start2; | 120 | return 1; |
121 | return 0; | ||
122 | } | 122 | } |
123 | 123 | ||
124 | int clean_sort_range(struct range *range, int az) | 124 | int clean_sort_range(struct range *range, int az) |