aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini2013-06-28 14:43:01 -0400
committerTom Rini2013-07-26 16:39:10 -0400
commite4c444b34b6ff6b347e552805ee89c48f85785bb (patch)
tree819affbbcf26cb4657003c9d880f31deec82ff83 /common
parent3864cb2133b8d4a45dbad603f7b0b9f051d617ff (diff)
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. Signed-off-by: Tom Rini <trini@ti.com> Reviewed-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_mmc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index e369ce39752..f27b4c277b6 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -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 */