[PATCH] lib: utils/fdt: Add full valid detection for __fdt_parse_region
Xiang W
wxjstz at 126.com
Wed Dec 7 09:12:49 PST 2022
The original code only detects region->order, and a certain relationship
needs to be satisfied between region->order and region->base. This patch
detects whether the region in fdt is valid through is_region_valid
Signed-off-by: Xiang W <wxjstz at 126.com>
---
lib/utils/fdt/fdt_domain.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/utils/fdt/fdt_domain.c b/lib/utils/fdt/fdt_domain.c
index bd0eec3..30a40dc 100644
--- a/lib/utils/fdt/fdt_domain.c
+++ b/lib/utils/fdt/fdt_domain.c
@@ -257,8 +257,6 @@ static int __fdt_parse_region(void *fdt, int domain_offset,
if (!val && len >= 4)
return SBI_EINVAL;
val32 = fdt32_to_cpu(*val);
- if (val32 < 3 || __riscv_xlen < val32)
- return SBI_EINVAL;
region->order = val32;
/* Read "mmio" DT property */
@@ -266,6 +264,9 @@ static int __fdt_parse_region(void *fdt, int domain_offset,
if (fdt_get_property(fdt, region_offset, "mmio", NULL))
region->flags |= SBI_DOMAIN_MEMREGION_MMIO;
+ if(!is_region_valid(region))
+ return SBI_EINVAL;
+
(*region_count)++;
return 0;
--
2.30.2
More information about the opensbi
mailing list