aboutsummaryrefslogtreecommitdiff
path: root/plat/rockchip/common
diff options
context:
space:
mode:
authorThomas Hebb <tommyhebb@gmail.com>2020-04-05 02:33:37 -0400
committerThomas Hebb <tommyhebb@gmail.com>2020-07-04 15:37:25 -0700
commite7b586987c0a46660aa8402f19d626a5489fe449 (patch)
tree48f2829a033605bc4d212b5282cfc6bf7c73af66 /plat/rockchip/common
parent568a8817281d6acb80580226dfcb4e39edcb74c1 (diff)
downloadtrusted-firmware-a-e7b586987c0a46660aa8402f19d626a5489fe449.tar.gz
rockchip: don't crash if we get an FDT we can't parse
When we parse the param from BL2, we try to parse it as a FDT and then, if that fails, as aux params. However, we don't sufficiently distinguish between failure modes in the first step: specifically, if we are given an FDT with good magic that we can't parse for some other reason (e.g. not enough space in our buffer), we still attempt to parse it as aux params even though that's guaranteed to fatal. Instead, we should either fail with a more descriptive message or continue to boot without parsing the FDT. This patch takes the latter approach, since all we currently get from the FDT is non-critical UART params. Signed-off-by: Thomas Hebb <tommyhebb@gmail.com> Change-Id: I1e98f1fcda4f78e6b45e86956288bafe58b113e4
Diffstat (limited to 'plat/rockchip/common')
-rw-r--r--plat/rockchip/common/params_setup.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/plat/rockchip/common/params_setup.c b/plat/rockchip/common/params_setup.c
index 2ff81eda79..aec53eee2e 100644
--- a/plat/rockchip/common/params_setup.c
+++ b/plat/rockchip/common/params_setup.c
@@ -230,12 +230,27 @@ static bool rk_aux_param_handler(struct bl_aux_param_header *param)
void params_early_setup(u_register_t plat_param_from_bl2)
{
+ int ret;
+
/*
* Test if this is a FDT passed as a platform-specific parameter
* block.
*/
- if (!dt_process_fdt(plat_param_from_bl2))
+ ret = dt_process_fdt(plat_param_from_bl2);
+ if (!ret) {
+ return;
+ } else if (ret != -FDT_ERR_BADMAGIC) {
+ /*
+ * If we found an FDT but couldn't parse it (e.g. corrupt, not
+ * enough space), return and don't attempt to parse the param
+ * as something else, since we know that will also fail. All
+ * we're doing is setting up UART, this doesn't need to be
+ * fatal.
+ */
+ WARN("%s: found FDT but could not parse: error %d\n",
+ __func__, ret);
return;
+ }
bl_aux_params_parse(plat_param_from_bl2, rk_aux_param_handler);
}