Commit 962ad59e25640e586e2bceabf67a628a27f8f508

Authored by Mike Frysinger
Committed by Scott Wood
1 parent 668a6b4591

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 <vapier@gentoo.org>
Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>

Showing 1 changed file with 2 additions and 0 deletions Side-by-side Diff

... ... @@ -266,6 +266,8 @@
266 266 u_char *char_ptr;
267 267  
268 268 blocksize = nand_info[0].erasesize;
  269 + if (!blocksize)
  270 + return 1;
269 271 len = min(blocksize, CONFIG_ENV_SIZE);
270 272  
271 273 while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {