[PATCH v2] lib: utils/fdt: Allow zero length mtime when parsing ACLINT
Guo Ren
guoren at kernel.org
Thu Oct 12 02:46:39 PDT 2023
On Thu, Oct 12, 2023 at 4:29 PM Inochi Amaoto <inochiama at outlook.com> wrote:
>
> 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 9ae7f09..972e529 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -891,8 +891,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;
> *out_addr1 = reg_addr;
> *out_size1 = reg_size;
>
> @@ -900,6 +902,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_size && *out_size1 == 0)
> + return SBI_ENODEV;
> if (out_addr2)
> *out_addr2 = reg_addr;
> if (out_size2)
> --
> 2.42.0
>
Reviewed-by: Guo Ren <guoren at kernel.org>
--
Best Regards
Guo Ren
More information about the opensbi
mailing list