summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2020-05-06 13:18:05 -0700
committerPatrick Georgi <pgeorgi@google.com>2020-05-08 15:29:22 +0000
commitf8f5650873451f64eab84d4b20248419bc19a0f5 (patch)
tree044f5e0504609687880f68ce406d1bf5f3c9517e /src
parent8211bde9c2a2cf80b82573df6122ca4dd3c764cf (diff)
downloadcoreboot-f8f5650873451f64eab84d4b20248419bc19a0f5.tar.xz
memrange: Break early from memranges_find_entry if limit is crossed
This change updates memranges_find_entry() to break and return early if the end address of the hole within the current range entry crosses the requested limit. This is because all range entries and maintained in increasing order and so none of the following range entries can satisfy the given request. Change-Id: I14e03946ddbbb5d254b23e9a9917da42960313a6 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41104 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/lib/memrange.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index 32f053de08..bc827d3635 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -400,8 +400,13 @@ static const struct range_entry *memranges_find_entry(struct memranges *ranges,
if (end > r->end)
continue;
+ /*
+ * If end for the hole in the current range entry goes beyond the requested
+ * limit, then none of the following ranges can satisfy this request because all
+ * range entries are maintained in increasing order.
+ */
if (end > limit)
- continue;
+ break;
return r;
}