Skip to contentSkip to conversation

spl_mmc.c: Detect missing kernel image in RAW MMC

PATCH In review Tom Rini 2 participants 3 messages Jun 28, 2013 – Jul 30, 2013

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 spl_mmc.c: Detect missing kernel image in RAW MMC

Currently, we assume that if we can read from MMC correctly, we have found a valid image. This is not the case as an empty area will read just fine. Add a check for a valid IH_MAGIC.

---
 common/spl/spl_mmc.c |    4 ++++
 1 file changed, 4 insertions(+)
common/spl/spl_mmc.c +4 -0
index 170fa38..d20f45d 100644
@@ -29,6 +29,7 @@
 #include <mmc.h>
 #include <fat.h>
 #include <version.h>
+#include <image.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,6 +47,9 @@ static int mmc_load_image_raw(struct mmc *mmc, unsigned long sector)
 	if (err == 0)
 		goto end;
 
+	if (image_get_magic(header) != IH_MAGIC)
+		return -1;
+
 	spl_parse_image_header(header);
 
 	/* convert size to sectors - round up */
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 spl_mmc.c: Detect missing kernel image in RAW MMC

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Tom" == Tom Rini <[email protected]> writes:

Tom> Currently, we assume that if we can read from MMC correctly, we have Tom> found a valid image. This is not the case as an empty area will read Tom> just fine. Add a check for a valid IH_MAGIC.

Tom> Signed-off-by: Tom Rini <[email protected]>

Tom> ---

 Tom>  common/spl/spl_mmc.c |    4 ++++

Tom> 1 file changed, 4 insertions(+)

Tom> diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c Tom> index 170fa38..d20f45d 100644
Tom> --- a/common/spl/spl_mmc.c
Tom> +++ b/common/spl/spl_mmc.c
Tom> @@ -29,6 +29,7 @@

 Tom>  #include <mmc.h>
 Tom>  #include <fat.h>
 Tom>  #include <version.h>

Tom> +#include <image.h>

Tom> DECLARE_GLOBAL_DATA_PTR;

Tom> @@ -46,6 +47,9 @@ static int mmc_load_image_raw(struct mmc *mmc, unsigned long sector)
Tom> if (err == 0)
Tom> goto end;

Tom> + if (image_get_magic(header) != IH_MAGIC)
Tom> + return -1;
Tom> +
Tom> spl_parse_image_header(header);

Tom> /* convert size to sectors - round up */
Tom> --
Tom> 1.7.9.5

Tom> _______________________________________________ Tom> U-Boot mailing list
Tom> U-Boot at lists.denx.de
Tom> http://lists.denx.de/mailman/listinfo/u-boot

Signature · 1 line
Bye, Peter Korsgaard
author
#2 lore raw
In reply to Tom Rini
Quoted 6 lines · Tom Rini

Currently, we assume that if we can read from MMC correctly, we have found a valid image. This is not the case as an empty area will read just fine. Add a check for a valid IH_MAGIC.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130730/ad1184c5/attachment.pgp>