summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Sutter <phil.sutter@viprinet.com>2013-02-21 18:21:56 +0100
committerScott Wood <scottwood@freescale.com>2013-02-22 19:59:53 -0600
commita1eac57a2001ecf86a46f520cd85ef8e9c8b3687 (patch)
tree1064af3d3d74305468904b6a1a00969c941fe8f3
parentb76a147b722565bde046f707a5cc92df8ea29738 (diff)
downloadu-boot-a1eac57a2001ecf86a46f520cd85ef8e9c8b3687.tar.gz
u-boot-a1eac57a2001ecf86a46f520cd85ef8e9c8b3687.tar.bz2
u-boot-a1eac57a2001ecf86a46f520cd85ef8e9c8b3687.zip
common/env_nand.c: calculate crc only when readenv was OK
Calculating the checksum of incompletely read data is useless. Signed-off-by: Phil Sutter <phil.sutter@viprinet.com> [scottwood@freescale.com: minor formatting fix] Signed-off-by: Scott Wood <scottwood@freescale.com>
-rw-r--r--common/env_nand.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/common/env_nand.c b/common/env_nand.c
index 382e8aec5e..5b69889c02 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -352,8 +352,10 @@ void env_relocate_spec(void)
puts("*** Warning - some problems detected "
"reading environment; recovered successfully\n");
- crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc;
- crc2_ok = crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc;
+ crc1_ok = !read1_fail &&
+ (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc);
+ crc2_ok = !read2_fail &&
+ (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc);
if (!crc1_ok && !crc2_ok) {
set_default_env("!bad CRC");