Skip to content

Commit

Permalink
[hermon] Avoid potential integer overflow when calculating memory map…
Browse files Browse the repository at this point in the history
…pings

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 de2c6fa commit 6ee62eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/drivers/infiniband/hermon.c
Expand Up @@ -2135,7 +2135,7 @@ static int hermon_map_vpm ( struct hermon *hermon,
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 6ee62eb

Please sign in to comment.