Skip to content

Commit

Permalink
[arbel] Avoid potential integer overflow when calculating memory mapp…
Browse files Browse the repository at this point in the history
…ings

When the area to be mapped straddles the 2GB boundary, the expression
(high+size) will overflow on the first loop iteration.  Fix by using
(end-size), which cannot underflow.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 21, 2017
1 parent 6ee62eb commit a5affc8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/drivers/infiniband/arbel.c
Expand Up @@ -1994,7 +1994,7 @@ static int arbel_map_vpm ( struct arbel *arbel,
if ( ( low - size ) >= start ) {
low -= size;
pa = low;
} else if ( ( high + size ) <= end ) {
} else if ( high <= ( end - size ) ) {
pa = high;
high += size;
} else {
Expand Down

0 comments on commit a5affc8

Please sign in to comment.