From: Peter Korsgaard Date: Fri, 28 Jun 2013 20:53:16 +0200 Subject: [U-Boot] [PATCH] spl_mmc.c: Detect missing kernel image in RAW MMC In-Reply-To: <1372444981-21305-1-git-send-email-trini@ti.com> (Tom Rini's message of "Fri, 28 Jun 2013 14:43:01 -0400") References: <1372444981-21305-1-git-send-email-trini@ti.com> Message-ID: <87mwqaysmb.fsf@dell.be.48ers.dk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de >>>>> "Tom" == Tom Rini 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 Reviewed-by: Peter Korsgaard 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 Tom> #include Tom> #include Tom> +#include 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 -- Bye, Peter Korsgaard