From f8f5650873451f64eab84d4b20248419bc19a0f5 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 6 May 2020 13:18:05 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41104 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/lib/memrange.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; }