Skip to content
Snippets Groups Projects
Commit 5c8c8fac authored by Andre Przywara's avatar Andre Przywara Committed by Jagan Teki
Browse files

SPL: FIT: improve error handling


At the moment we ignore any errors due to missing FIT properties,
instead go ahead and calculate our addresses with the -1 return value.
Fix this and bail out if any of the mandatory properties are missing.

Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Reviewed-by: default avatarKever Yang <kever.yang@rock-chips.com>
Tested-by: default avatarKever Yang <kever.yang@rock-chips.com>
Tested-by: default avatarJagan Teki <jagan@openedev.com>
Reviewed-by: default avatarJagan Teki <jagan@openedev.com>
parent 736806fb
No related branches found
No related tags found
No related merge requests found
...@@ -11,14 +11,17 @@ ...@@ -11,14 +11,17 @@
#include <libfdt.h> #include <libfdt.h>
#include <spl.h> #include <spl.h>
#define FDT_ERROR ((ulong)(-1))
static ulong fdt_getprop_u32(const void *fdt, int node, const char *prop) static ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
{ {
const u32 *cell; const u32 *cell;
int len; int len;
cell = fdt_getprop(fdt, node, prop, &len); cell = fdt_getprop(fdt, node, prop, &len);
if (len != sizeof(*cell)) if (!cell || len != sizeof(*cell))
return -1U; return FDT_ERROR;
return fdt32_to_cpu(*cell); return fdt32_to_cpu(*cell);
} }
...@@ -222,7 +225,11 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, ...@@ -222,7 +225,11 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
/* Get its information and set up the spl_image structure */ /* Get its information and set up the spl_image structure */
data_offset = fdt_getprop_u32(fit, node, "data-offset"); data_offset = fdt_getprop_u32(fit, node, "data-offset");
if (data_offset == FDT_ERROR)
return -ENOENT;
data_size = fdt_getprop_u32(fit, node, "data-size"); data_size = fdt_getprop_u32(fit, node, "data-size");
if (data_size == FDT_ERROR)
return -ENOENT;
load = fdt_getprop_u32(fit, node, "load"); load = fdt_getprop_u32(fit, node, "load");
debug("data_offset=%x, data_size=%x\n", data_offset, data_size); debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
spl_image->load_addr = load; spl_image->load_addr = load;
...@@ -265,6 +272,10 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, ...@@ -265,6 +272,10 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
} }
fdt_offset = fdt_getprop_u32(fit, node, "data-offset"); fdt_offset = fdt_getprop_u32(fit, node, "data-offset");
fdt_len = fdt_getprop_u32(fit, node, "data-size"); fdt_len = fdt_getprop_u32(fit, node, "data-size");
if (fdt_offset == FDT_ERROR || fdt_len == FDT_ERROR) {
debug("%s: cannot load FDT data\n" __func__);
return -ENOENT;
}
/* /*
* Read the device tree and place it after the image. There may be * Read the device tree and place it after the image. There may be
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment