lib: utils/fdt: Allow zero length mtime when parsing ACLINT
PATCH 1/1 lib: utils/fdt: Allow zero length mtime when parsing ACLINT
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.
--- lib/utils/fdt/fdt_helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/utils/fdt/fdt_helper.c +5 -1
@@ -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 ; *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)
Signature · 1 line
2.42.0
PATCH 1/1 lib: utils/fdt: Allow zero length mtime when parsing ACLINT
? 2023-10-12???? 07:25 +0800?Inochi Amaoto???
Quoted 23 lines
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 <[email protected]>---
?lib/utils/fdt/fdt_helper.c | 6 +++++-
?1 file changed, 5 insertions(+), 1 deletion(-)lib/utils/fdt/fdt_helper.c +0
-0@@ -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);lib/utils/fdt/fdt_helper.c +1
-1-if (rc <0 || !reg_size) +if (rc <0 )? return
SBI_ENODEV;
lib/utils/fdt/fdt_helper.c int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, · line 903
Quoted 2 lines
lib/utils/fdt/fdt_helper.c +2
-0+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
Quoted 17 lines
?
*out_addr1=reg_addr;
?*out_size1=reg_size;
?lib/utils/fdt/fdt_helper.c +2
-0@@ -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)Signature · 1 line
2.42.0
PATCH 1/1 lib: utils/fdt: Allow zero length mtime when parsing ACLINT
Quoted 19 lines
? 2023-10-12???? 07:25 +0800?Inochi Amaoto???
Quoted 18 lines
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 <[email protected]>--- lib/utils/fdt/fdt_helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)lib/utils/fdt/fdt_helper.c +0
-0@@ -897,8 +897,10 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
Quoted 10 lines
lib/utils/fdt/fdt_helper.c int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, · line 903
Quoted 7 lines
lib/utils/fdt/fdt_helper.c +3
-1rc =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_sizehere, should add a check where this function is called. Because reg_size=0 is only legal underwithout_mtime.
This check is not abandoned, but delayed.
Quoted 5 lines
Regards,
Xiang WQuoted 3 lines
lib/utils/fdt/fdt_helper.c +0
-0*out_addr1 = reg_addr; *out_size1 = reg_size;
Quoted 7 lines
lib/utils/fdt/fdt_helper.c int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, · line 912
Quoted 6 lines
lib/utils/fdt/fdt_helper.c +2
-0@@ -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 ;
The reg_size of the first pair is checked here.
It seems I should check reg_size here, will fix.
Quoted 9 lines
Quoted 7 lines
lib/utils/fdt/fdt_helper.c +0
-1if (out_addr2) *out_addr2 = reg_addr;if (out_size2) --2.42.0