summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian J. Nemec <bnemec@chromium.org>2020-02-14 16:02:04 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-20 06:07:33 +0000
commitff478f1855ee68b0adfec3e9724663dc1821970c (patch)
tree1ac58e2b44c282ef48ed627c5d370ad2fe3798fb
parent3b2b7b26d3c033d4a75d67b081dbd4d6a3d3c74e (diff)
downloadchrome-ec-ff478f1855ee68b0adfec3e9724663dc1821970c.tar.gz
common/flash: Add validation to persist_state size.
Adds a check to validate the size of the persist_state to verify that it fits within the space allocated. BUG=b:149509270 TEST=Verified that when the sizeof(persist_state) less than or equal to CONFIG_FW_PSTATE_SIZE that no change occurs. Flash space remains the same and read / writes are functional. Verified that when the persist_state is enlarged, the BUILD_ASSERT check fails giving a compile time error. Branch=none Change-Id: Ia31329ec7817cef71e3835c94028951eaf71fd80 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2057968 Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org>
-rw-r--r--common/flash.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/flash.c b/common/flash.c
index 00d13d2693..4b3a5fae69 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -64,6 +64,8 @@ struct persist_state {
BUILD_ASSERT(sizeof(struct persist_state) % CONFIG_FLASH_WRITE_SIZE == 0);
#endif
+BUILD_ASSERT(sizeof(struct persist_state) <= CONFIG_FW_PSTATE_SIZE);
+
#else /* !CONFIG_FLASH_PSTATE_BANK */
/*