[PATCH] lib: utils/fdt: Allow zero length mtime when parsing ACLINT
Xiang W
wxjstz at 126.com
Wed Oct 11 20:27:07 PDT 2023
在 2023-10-12星期四的 07:25 +0800,Inochi Amaoto写道:
> Currently, the fdt_parse_aclint_node() does not allow the first reg to
> be zero length. This may cause the parser to fail when the ACLINT does
> not support mtime.
>
> To be robust, delay the check of first reg in fdt_parse_aclint_node()
> so the parser can handle ACLINT without mtime support.
>
> Signed-off-by: Inochi Amaoto <inochiama at outlook.com>
> ---
> lib/utils/fdt/fdt_helper.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index c97f09d..6b4ef38 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -897,8 +897,10 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
>
> rc = fdt_get_node_addr_size(fdt, nodeoffset, 0,
> ®_addr, ®_size);
> - if (rc < 0 || !reg_size)
> + if (rc < 0)
> return SBI_ENODEV;
> + if (!reg_size)
> + reg_addr = reg_size = 0;
If abandon checking reg_size here, should add a check where this function
is called. Because reg_size=0 is only legal under without_mtime.
Regards,
Xiang W
> *out_addr1 = reg_addr;
> *out_size1 = reg_size;
>
> @@ -906,6 +908,8 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
> ®_addr, ®_size);
> if (rc < 0 || !reg_size)
> reg_addr = reg_size = 0;
> + if (!reg_addr && *out_size1 == 0)
> + return SBI_ENODEV;
> if (out_addr2)
> *out_addr2 = reg_addr;
> if (out_size2)
> --
> 2.42.0
>
>
More information about the opensbi
mailing list