Richard Spiegel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31473
Change subject: drivers/spi/spi_flash.c: Avoid static scan false positive ......................................................................
drivers/spi/spi_flash.c: Avoid static scan false positive
Static scan-build indicates a possible invalid return from function spi_flash_cmd_erase(). The root cause is because the scan believes it's possible for offset to be above the end address in the first pass, thus not setting a value for variable ret. By making sure that input len can't be negative we instruct the scan that the loop will be executed at least once.
BUG=b:112253891 TEST=build grunt
Change-Id: If548728ff90b755c69143eabff6aeff01e8fd483 Signed-off-by: Richard Spiegel richard.spiegel@silverbackltd.com --- M src/drivers/spi/spi_flash.c 1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31473/1
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 204f607..5b5b319 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -204,14 +204,14 @@ printk(BIOS_WARNING, "SF: Erase offset/length not multiple of erase size\n"); return -1; } - if (len == 0) { + if (len <= 0) { printk(BIOS_WARNING, "SF: Erase length cannot be 0\n"); return -1; }
cmd[0] = flash->erase_cmd; start = offset; - end = start + len; + end = offset + len;
while (offset < end) { spi_flash_addr(offset, cmd);