SPL: Let spl_parse_image_header() return value

Allow the spl_parse_image_header() to return value. This is convenient
for controlling the SPL boot flow if the loaded image is corrupted.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Peng Fan <van.freenix@gmail.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@konsulko.com>
diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c
index ca56fe9..46c98a9 100644
--- a/drivers/mtd/spi/spi_spl_load.c
+++ b/drivers/mtd/spi/spi_spl_load.c
@@ -23,6 +23,8 @@
 static int spi_load_image_os(struct spi_flash *flash,
 			     struct image_header *header)
 {
+	int err;
+
 	/* Read for a header, parse or error out. */
 	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, 0x40,
 		       (void *)header);
@@ -30,7 +32,9 @@
 	if (image_get_magic(header) != IH_MAGIC)
 		return -1;
 
-	spl_parse_image_header(header);
+	err = spl_parse_image_header(header);
+	if (err)
+		return err;
 
 	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
 		       spl_image.size, (void *)spl_image.load_addr);
@@ -81,7 +85,9 @@
 		if (err)
 			return err;
 
-		spl_parse_image_header(header);
+		err = spl_parse_image_header(header);
+		if (err)
+			return err;
 		err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
 			       spl_image.size, (void *)spl_image.load_addr);
 	}