diff mbox series

[v3,2/4] spl: fit: fail fit loading in case of FDT appending error

Message ID 20200527115621.1062-3-dariobin@libero.it
State Accepted
Commit 585b468a8c73df0445e994443a39869697fc53a8
Headers show
Series Fix the SPL loading of a FIT image from NAND | expand

Commit Message

Dario Binacchi May 27, 2020, 11:56 a.m. UTC
If uboot does not embed its device tree and the FIT loading function
returns error in case of failure in the FDT append, the redundant itb
image could be loaded.

cc: Michael Trimarchi <michael at amarulasolutions.com>
Signed-off-by: Dario Binacchi <dariobin at libero.it>
Reviewed-by: Michael Trimarchi <michael at amarulasolutions.com>

---

Changes in v3: None
Changes in v2:
 - Replace CONFIG_IS_ENABLED(OF_EMBED) with IS_ENABLED(CONFIG_OF_EMBED))

 common/spl/spl_fit.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Simon Glass May 31, 2020, 2:08 p.m. UTC | #1
On Wed, 27 May 2020 at 05:56, Dario Binacchi <dariobin at libero.it> wrote:
>
> If uboot does not embed its device tree and the FIT loading function

U-Boot

> returns error in case of failure in the FDT append, the redundant itb
> image could be loaded.
>
> cc: Michael Trimarchi <michael at amarulasolutions.com>
> Signed-off-by: Dario Binacchi <dariobin at libero.it>
> Reviewed-by: Michael Trimarchi <michael at amarulasolutions.com>
>
> ---
>
> Changes in v3: None
> Changes in v2:
>  - Replace CONFIG_IS_ENABLED(OF_EMBED) with IS_ENABLED(CONFIG_OF_EMBED))
>
>  common/spl/spl_fit.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>
diff mbox series

Patch

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index f581a22421..365104fe02 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -619,9 +619,12 @@  int spl_load_simple_fit(struct spl_image_info *spl_image,
 	 * Booting a next-stage U-Boot may require us to append the FDT.
 	 * We allow this to fail, as the U-Boot image might embed its FDT.
 	 */
-	if (spl_image->os == IH_OS_U_BOOT)
-		spl_fit_append_fdt(spl_image, info, sector, fit,
-				   images, base_offset);
+	if (spl_image->os == IH_OS_U_BOOT) {
+		ret = spl_fit_append_fdt(spl_image, info, sector, fit,
+					 images, base_offset);
+		if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0)
+			return ret;
+	}
 
 	firmware_node = node;
 	/* Now check if there are more images for us to load */