diff mbox series

[2/4] lmb: handle scenario of of encompassing overlap

Message ID 20250213131104.186663-3-sughosh.ganu@linaro.org
State New
Headers show
Series lmb: miscellaneous fixes and improvements | expand

Commit Message

Sughosh Ganu Feb. 13, 2025, 1:11 p.m. UTC
The lmb_fix_over_lap_regions() function is called if the added region
overlaps with an existing region. The function then fixes the overlap
and removes the redundant region. However, it makes an assumption that
the overlap would not encompass the existing region, and in such a
scenario, it prints a message and returns without making the
fix. Handle the case of an encompassing overlap also in the function.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reported-by: Quentin Schulz <quentin.schulz@cherry.de>
---

Note: To be applied after an A-b/R-b/T-b from the original author
of the lmb_fix_over_lap_regions() function on this

 lib/lmb.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/lib/lmb.c b/lib/lmb.c
index aeaf120f57d..a5216bdccc7 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -111,11 +111,9 @@  static void lmb_fix_over_lap_regions(struct alist *lmb_rgn_lst,
 	phys_addr_t base2 = rgn[r2].base;
 	phys_size_t size2 = rgn[r2].size;
 
-	if (base1 + size1 > base2 + size2) {
-		printf("This will not be a case any time\n");
-		return;
-	}
-	rgn[r1].size = base2 + size2 - base1;
+	if (base1 + size1 < base2 + size2)
+		rgn[r1].size = base2 + size2 - base1;
+
 	lmb_remove_region(lmb_rgn_lst, r2);
 }