summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Pronin <apronin@chromium.org>2019-09-27 19:55:21 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-04 20:56:44 +0000
commita62fac4d522264fedd1fe44895b4f1fae7e9e530 (patch)
tree79f1f525636f1d3e5780a76af2f5c5d1a0a930e1
parent8edcc006fe29232e764a717ce40588aa0cf8b226 (diff)
downloadchrome-ec-a62fac4d522264fedd1fe44895b4f1fae7e9e530.tar.gz
cr50: nvmem: fix list_index after erased header at page end
Before this CL, if the last 4 bytes of the last page were not written, after reading those bytes to check if they contain a header, the mt was rewinded to the end of the previous container, but list_index stayed pointing to the next page. Which could lead to skipping pages when creating the next container. This CL fixes it. BRANCH=none BUG=b:140139297 TEST=running test_nvmem with CL:1828184 applied doesn't lead to error 14 Change-Id: Icc8d1b8eb5cfc0f0230706ed386c2ef9b4936cae Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1830372 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit 56f611ffdc7a52f192f898cb15e1eb7e9e940ba2) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1835039 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit feb0714c2d946b00cbf3ab55cb5e1ec4cae978d0) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1838877
-rw-r--r--common/new_nvmem.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/common/new_nvmem.c b/common/new_nvmem.c
index 58b9b46117..e9fa2c1a0c 100644
--- a/common/new_nvmem.c
+++ b/common/new_nvmem.c
@@ -768,10 +768,10 @@ test_export_static enum ec_error_list get_next_object(struct access_tracker *at,
/*
* If the container header happened to span between
- * two pages - roll back page index saved in the
- * context.
+ * two pages or end at the page boundary - roll back
+ * page index saved in the context.
*/
- if ((CONFIG_FLASH_BANK_SIZE - at->mt.data_offset) <
+ if ((CONFIG_FLASH_BANK_SIZE - at->mt.data_offset) <=
sizeof(struct nn_container))
at->list_index--;