diff mbox series

common: spl: spl_fit.c: report an error on hash check fail

Message ID 20201124151505.4782-1-philippe.reynes@softathome.com
State Under Review
Delegated to: Tom Rini
Headers show
Series common: spl: spl_fit.c: report an error on hash check fail | expand

Commit Message

Philippe REYNES Nov. 24, 2020, 3:15 p.m. UTC
When the hash check fails on a loadable image, the SPL/TPL simply
jump to the next one. This commit changes this behaviour, when the
hash check fails on a loadable image, the function spl_load_simple_fit
stops and report an error.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 common/spl/spl_fit.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Simon Glass Nov. 30, 2020, 8:12 p.m. UTC | #1
On Tue, 24 Nov 2020 at 08:15, Philippe Reynes
<philippe.reynes@softathome.com> wrote:
>
> When the hash check fails on a loadable image, the SPL/TPL simply
> jump to the next one. This commit changes this behaviour, when the
> hash check fails on a loadable image, the function spl_load_simple_fit
> stops and report an error.
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> ---
>  common/spl/spl_fit.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

This should have a test. We have sandbox SPL test support now so it
should not be too hard.
diff mbox series

Patch

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 6418062b93..0de4a2b543 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -667,8 +667,11 @@  int spl_load_simple_fit(struct spl_image_info *spl_image,
 
 		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
 					 &image_info);
-		if (ret < 0)
-			continue;
+		if (ret < 0) {
+			printf("%s: can't load image loadables index %d (ret = %d)\n",
+			       __func__, index, ret);
+			return ret;
+		}
 
 		if (!spl_fit_image_get_os(fit, node, &os_type))
 			debug("Loadable is %s\n", genimg_get_os_name(os_type));