]> git.sur5r.net Git - u-boot/commitdiff
env_nand: return error when no device is found
authorMike Frysinger <vapier@gentoo.org>
Thu, 12 Aug 2010 03:42:26 +0000 (23:42 -0400)
committerScott Wood <scottwood@freescale.com>
Fri, 13 Aug 2010 18:32:42 +0000 (13:32 -0500)
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 <vapier@gentoo.org>
Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>
common/env_nand.c

index a5e1038315bd01c520c25809e29fad01359d88d1..d38bcca1b81119c482ab49b119fb8ca2aff1b40a 100644 (file)
@@ -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) {