]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
common/env_nand.c: calculate crc only when readenv was OK
authorPhil Sutter <phil.sutter@viprinet.com>
Thu, 21 Feb 2013 17:21:56 +0000 (18:21 +0100)
committerScott Wood <scottwood@freescale.com>
Sat, 23 Feb 2013 01:59:53 +0000 (19:59 -0600)
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>
common/env_nand.c

index 382e8aec5e2554627801b7b93188538d9c38ecef..5b69889c02a70fc7f167eab7a04864ac3a2ebdfc 100644 (file)
@@ -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");