spl_invoke_opensbi() takes the next-stage entry point from a
/fit-images node with fit_image_get_entry(), falling back to
fit_image_get_load(). fit_image_get_address() returns -1 without
assigning the caller's ulong, both when the property is absent and
when the address does not fit in a target ulong, so os_entry stays
uninitialised when a node has neither property.
ret was not tested after the fallback, so that uninitialised stack
value became opensbi_info.next_addr, the address OpenSBI jumps to when
it hands control to S-mode.
spl_opensbi_find_os_node() selects the first /fit-images subnode whose
os property matches the requested type and does not require an entry
or load property, so such a node is reachable.
Fail the boot instead, matching how the rest of the function handles a
device tree it cannot use.
Fixes: caa7fc2c5775 ("spl: Use standard FIT entries")
Signed-off-by: Sebastian Alba Vives <[email protected]>
---
common/spl/spl_opensbi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index 0ed6afeacc..a3881f6597 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -97,6 +97,11 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info
*spl_image)
ret = fit_image_get_entry(spl_image->fdt_addr, os_node, &os_entry);
if (ret)
ret = fit_image_get_load(spl_image->fdt_addr, os_node,
&os_entry);
+ if (ret) {
+ pr_err("Can't get entry point or load address for %s, %d\n",
+ genimg_get_os_name(os_type), ret);
+ hang();
+ }
/* Prepare opensbi_info object */
opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
--
2.43.0