summaryrefslogtreecommitdiff
path: root/common/new_nvmem.c
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-01 06:18:40 +0000
commit56f611ffdc7a52f192f898cb15e1eb7e9e940ba2 (patch)
tree61ae39e54bd1f3fa349d13ad990051dc48c416af /common/new_nvmem.c
parent831d113c640edbc2a63cd03436a840b0688beab8 (diff)
downloadchrome-ec-56f611ffdc7a52f192f898cb15e1eb7e9e940ba2.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>
Diffstat (limited to 'common/new_nvmem.c')
-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--;