]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl_mmc.c: Detect missing kernel image in RAW MMC
authorTom Rini <trini@ti.com>
Fri, 28 Jun 2013 18:43:01 +0000 (14:43 -0400)
committerTom Rini <trini@ti.com>
Fri, 26 Jul 2013 20:39:10 +0000 (16:39 -0400)
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.

Signed-off-by: Tom Rini <trini@ti.com>
Reviewed-by: Peter Korsgaard <jacmet@sunsite.dk>
common/spl/spl_mmc.c

index e369ce3975253556e850933cbb740932979a3436..f27b4c277b645ed0555a6df27fb3e04d9e9a240b 100644 (file)
@@ -13,6 +13,7 @@
 #include <mmc.h>
 #include <fat.h>
 #include <version.h>
+#include <image.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -30,6 +31,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 */