As pointed out by Wolfgang Denk, the problem with this fix is that while
interactive users will see that we have found one part of the
environment failed and are using the other, progmatic use will not see
this and can lead to problems.
Signed-off-by: Tom Rini <trini@konsulko.com>
-
- if (!flash_io(O_RDONLY)) {
- crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
- crc0_ok = (crc0 == *environment.crc);
- } else if (have_redund_env) {
- /*
- * to give the redundant env a chance, maybe it's good:
- * mark env crc0 invalid then test below if crc1 is ok
- */
- crc0_ok = 0;
- } else {
+ if (flash_io(O_RDONLY)) {
ret = -EIO;
goto open_cleanup;
}
ret = -EIO;
goto open_cleanup;
}
+ crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE);
+
+ crc0_ok = (crc0 == *environment.crc);
if (!have_redund_env) {
if (!crc0_ok) {
fprintf(stderr,
if (!have_redund_env) {
if (!crc0_ok) {
fprintf(stderr,
*/
environment.image = addr1;
if (flash_io(O_RDONLY)) {
*/
environment.image = addr1;
if (flash_io(O_RDONLY)) {
- crc1_ok = 0;
- } else {
- crc1 = crc32(0, (uint8_t *)redundant->data, ENV_SIZE);
- crc1_ok = (crc1 == redundant->crc);
+ ret = -EIO;
+ goto open_cleanup;
}
/* Check flag scheme compatibility */
}
/* Check flag scheme compatibility */
+ crc1 = crc32(0, (uint8_t *)redundant->data, ENV_SIZE);
+
+ crc1_ok = (crc1 == redundant->crc);
flag1 = redundant->flags;
if (crc0_ok && !crc1_ok) {
flag1 = redundant->flags;
if (crc0_ok && !crc1_ok) {