From: Mike Frysinger Date: Thu, 12 Aug 2010 03:42:26 +0000 (-0400) Subject: env_nand: return error when no device is found X-Git-Tag: v2010.09-rc1~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=962ad59e25640e586e2bceabf67a628a27f8f508;p=u-boot env_nand: return error when no device is found Currently, if there is an error probing the NAND chip and the env is based in NAND, the readenv() function will use a NULL function pointer and thus jump to address 0. Here I just check for a non-zero value of blocksize as that shouldn't be zero when a valid device is found, but perhaps there is a better way for someone familiar with the NAND internals to suggest. Signed-off-by: Mike Frysinger Tested-by: Ben Gardiner --- diff --git a/common/env_nand.c b/common/env_nand.c index a5e1038315..d38bcca1b8 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -266,6 +266,8 @@ int readenv (size_t offset, u_char * buf) u_char *char_ptr; blocksize = nand_info[0].erasesize; + if (!blocksize) + return 1; len = min(blocksize, CONFIG_ENV_SIZE); while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {