diff mbox series

[1/4] include: sbi_utils: fixup fdt_get_address

Message ID 20240606091723.896477-2-wxjstz@126.com
State Changes Requested
Headers show
Series Initialize the console as early as possible | expand

Commit Message

Xiang W June 6, 2024, 9:17 a.m. UTC
root.next_arg1 will be NULL before sbi_domain_init, which will cause
fdt address to be NULL before sbi_domain is initialized. This patch
fixes this.

Signed-off-by: Xiang W <wxjstz@126.com>
---
 include/sbi_utils/fdt/fdt_helper.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h
index ab4a80f..67e6dc7 100644
--- a/include/sbi_utils/fdt/fdt_helper.h
+++ b/include/sbi_utils/fdt/fdt_helper.h
@@ -116,7 +116,9 @@  int fdt_parse_compat_addr(void *fdt, uint64_t *addr,
 
 static inline void *fdt_get_address(void)
 {
-	return (void *)root.next_arg1;
+	if (root.next_arg1)
+		return (void *)root.next_arg1;
+	return sbi_scratch_thishart_arg1_ptr();
 }
 
 #endif /* __FDT_HELPER_H__ */