From 69d0f6e2c66c164bd4de5d279ace4b303db04f1b Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 9 Sep 2019 22:42:19 +0200 Subject: common/flash.c: Support finding the flash_bank_index for offset 0 According to the algorithm that's always the first entry, but it always returned -1 so far. Found by Coverity Scan #174434 BUG=none BRANCH=none TEST=none Change-Id: Idd3f2794b559bea47f8425791351a8d0bc1424d6 Signed-off-by: Patrick Georgi Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1793583 Reviewed-by: Daisuke Nojiri Tested-by: Patrick Georgi Commit-Queue: Patrick Georgi --- common/flash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/flash.c b/common/flash.c index 1127c2cfcb..632153a99b 100644 --- a/common/flash.c +++ b/common/flash.c @@ -155,6 +155,9 @@ int flash_bank_index(int offset) { int bank_offset = 0, i; + if (offset == 0) + return bank_offset; + for (i = 0; i < ARRAY_SIZE(flash_bank_array); i++) { int all_sector_size = flash_bank_array[i].count << flash_bank_array[i].size_exp; -- cgit v1.2.1