Browse Source

[hermon] Avoid potential integer overflow when calculating memory mappings

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>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
6ee62eb242
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      src/drivers/infiniband/hermon.c

+ 1
- 1
src/drivers/infiniband/hermon.c View File

2135
 		if ( ( low - size ) >= start ) {
2135
 		if ( ( low - size ) >= start ) {
2136
 			low -= size;
2136
 			low -= size;
2137
 			pa = low;
2137
 			pa = low;
2138
-		} else if ( ( high + size ) <= end ) {
2138
+		} else if ( high <= ( end - size ) ) {
2139
 			pa = high;
2139
 			pa = high;
2140
 			high += size;
2140
 			high += size;
2141
 		} else {
2141
 		} else {

Loading…
Cancel
Save