mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-12-08 01:11:19 +00:00
lib: sbi: fix covered regions handling in sanitize_domain()
In the sanitize_domain, code that checks for the case when one
memory region covered by the other, was never executed. Quote:
/* Sort the memory regions */
for (i = 0; i < (count - 1); i++) {
<snip>
}
/* Remove covered regions */
while(i < (count - 1)) {
Here "while" loop never executed because condition "i < (count - 1)"
is always false after the "for" loop just above.
In addition, when clearing region, "root_memregs_count"
should be adjusted as well, otherwise code that adds memory region
in the "root_add_memregion" will use wrong position:
/* Append the memregion to root memregions */
nreg = &root.regions[root_memregs_count];
empty entry will be created in the middle of regions array, new
regions will be added after this empty entry while sanitizing code
will stop when reaching empty entry.
Fixes: 3b03cdd60c ("lib: sbi: Add regions merging when sanitizing domain region")
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20251111104327.1170919-2-vladimir.kondratiev@mobileye.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
committed by
Anup Patel
parent
825d0e918a
commit
4997eb28da
@@ -431,7 +431,7 @@ static int sanitize_domain(struct sbi_domain *dom)
|
||||
}
|
||||
|
||||
/* Remove covered regions */
|
||||
while(i < (count - 1)) {
|
||||
for (i = 0; i < (count - 1);) {
|
||||
is_covered = false;
|
||||
reg = &dom->regions[i];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user