@@ -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;
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@126.com> --- lib/utils/fdt/fdt_domain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)