Skip to contentSkip to conversation

env_nand: return error when no device is found

PATCH New Mike Frysinger 3 participants 3 messages Aug 12, 2010 – Aug 13, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 common/env_nand.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
common/env_nand.c +2 -0
index a5e1038..d38bcca 100644
@@ -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) {
Signature · 1 line
1.7.2
#1 lore raw

PATCH 1/1 env_nand: return error when no device is found

Quoted 9 lines · Mike Frysinger

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.

Applies clean to 69a2a4d9a5884a6f2d04a551308980d452b9b349 of
git://git.denx.de/u-boot.git.

Tested on da850evm_config with NAND enabled, board boots fine.

---
Nanometrics Inc.
http://www.nanometrics.ca

#2 lore raw

PATCH 1/1 env_nand: return error when no device is found

In reply to Mike Frysinger
Quoted 4 lines · Mike Frysinger

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.

Quoted 8 lines

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.

---
 common/env_nand.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Applied to u-boot-nand-flash.

-Scott