From: Anup Patel Date: Thu, 20 May 2021 10:17:07 +0000 (+0530) Subject: lib: Check region base for merging in sbi_domain_root_add_memregion() X-Git-Tag: v1.3~528 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2dbbc0577e326b6dc1babaa53fb46605c996a72;p=platform%2Fkernel%2Fopensbi-spacemit.git lib: Check region base for merging in sbi_domain_root_add_memregion() We can merge region B onto region A only if base of region A is aligned to region A order + 1. Signed-off-by: Anup Patel Reviewed-by: Atish Patra Reviewed-by: Xiang W --- diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 84f30b9..3096af0 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -511,7 +511,8 @@ int sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg) if (!nreg1->order) continue; - if ((nreg->base + BIT(nreg->order)) == nreg1->base && + if (!(nreg->base & (BIT(nreg->order + 1) - 1)) && + (nreg->base + BIT(nreg->order)) == nreg1->base && nreg->order == nreg1->order && nreg->flags == nreg1->flags) { nreg->order++;