Skip to contentSkip to conversation

env: mmc: Fix offset issue for env save

PATCH In review Ye Li 3 participants 3 messages Jan 31, 2023 – Feb 7, 2023

lore
Share & tools
lore

Ye Li

author
#0 lore raw

PATCH 1/1 env: mmc: Fix offset issue for env save

Fix the issue in commit 46c9016 (env: mcc: Drop unnecessary #ifdefs) If CONFIG_SYS_REDUNDAND_ENVIRONMENT is not defined, the offset value becomes undetermined, so write env to unexpected offset.

---
 env/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
env/mmc.c +4 -4
index 8576141..5b01f65 100644
@@ -273,11 +273,11 @@ static int env_mmc_save(void)
 			if (ret)
 				goto fini;
 		}
+	}
 
-		if (mmc_get_env_addr(mmc, copy, &offset)) {
-			ret = 1;
-			goto fini;
-		}
+	if (mmc_get_env_addr(mmc, copy, &offset)) {
+		ret = 1;
+		goto fini;
 	}
 
 	printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", dev);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ye Li

Fix the issue in commit 46c9016 (env: mcc: Drop unnecessary #ifdefs) If CONFIG_SYS_REDUNDAND_ENVIRONMENT is not defined, the offset value becomes undetermined, so write env to unexpected offset.

Best Regards,
Jaehoon Chung

Quoted 24 lines
---
 env/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
env/mmc.c +4 -4
index 8576141..5b01f65 100644
@@ -273,11 +273,11 @@ static int env_mmc_save(void)
 			if (ret)
 				goto fini;
 		}
+	}
 
-		if (mmc_get_env_addr(mmc, copy, &offset)) {
-			ret = 1;
-			goto fini;
-		}
+	if (mmc_get_env_addr(mmc, copy, &offset)) {
+		ret = 1;
+		goto fini;
 	}
 
 	printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", dev);