diff options
-rw-r--r-- | chip/lm4/flash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c index d2d670c8ef..62e04ec8c9 100644 --- a/chip/lm4/flash.c +++ b/chip/lm4/flash.c @@ -96,6 +96,10 @@ int flash_physical_write(int offset, int size, const char *data) if (all_protected) return EC_ERROR_ACCESS_DENIED; + /* Fail if offset, size, and data aren't at least word-aligned */ + if ((offset | size | (uint32_t)(uintptr_t)data) & 3) + return EC_ERROR_INVAL; + /* Get initial write buffer index and page */ LM4_FLASH_FMA = offset & ~(FLASH_FWB_BYTES - 1); i = (offset >> 2) & (FLASH_FWB_WORDS - 1); |