From: Tom Rini Date: Fri, 28 Jun 2013 14:43:01 -0400 Subject: [U-Boot] [PATCH] spl_mmc.c: Detect missing kernel image in RAW MMC Message-ID: <1372444981-21305-1-git-send-email-trini@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- common/spl/spl_mmc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 170fa38..d20f45d 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -29,6 +29,7 @@ #include #include #include +#include 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 */ -- 1.7.9.5