From 2c4432f609bc261603f40fa0e5eba5b975514477 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Mon, 7 Jul 2014 12:51:52 -0700 Subject: [PATCH] flash: Fix bad check for flash_is_erased() This caused all platforms to check only the first 25% of each page to see if it's already erased. Fortunately, we tend to fill flash pages from the beginning, so in normal usage we don't hit this bug. BUG=chrome-os-partner:30281 BRANCH=all (if convenient) TEST=Make sure CONFIG_CMD_FLASH is defined. Then at the EC console: flasherase 0x1f000 0x400 rw 0x1f3e0 -> 0xffffffff flashwrite 0x1f3e0 0x20 rw 0x1f3e0 -> 0x03020100 flasherase 0x1f000 0x400 rw 0x1f3e0 -> 0x03020100 (bad!) or 0xffffffff (good) Change-Id: If78b08b5e0414993a440bc8cd707b5ce70eb1a0a Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/206891 Reviewed-by: Dmitry Torokhov Reviewed-by: Alec Berg --- common/flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/flash.c b/common/flash.c index 770609e42d..b19096b9e3 100644 --- a/common/flash.c +++ b/common/flash.c @@ -120,7 +120,7 @@ int flash_is_erased(uint32_t offset, int size) (const char **)&ptr) < 0) return 0; - for (size /= sizeof(uint32_t); size > 0; size -= 4, ptr++) + for (size /= sizeof(uint32_t); size > 0; size--, ptr++) if (*ptr != CONFIG_FLASH_ERASED_VALUE32) return 0;