Richard Spiegel has uploaded this change for review. ( https://review.coreboot.org/27952
Change subject: drivers/spi/spi_flash.c: Check input paarameter ......................................................................
drivers/spi/spi_flash.c: Check input paarameter
In procedure spi_flash_cmd_erase(), parameter "len" is not validated and could lead to the return of an invalid (not-initialized) value. Validate the parameter early on.
BUG=b:112253891 TEST=Build and boot grunt.
Change-Id: I0b5129a15c9e0ea45f4dba4ab0729196cb64699b Signed-off-by: Richard Spiegel richard.spiegel@silverbackltd.com --- M src/drivers/spi/spi_flash.c 1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/52/27952/1
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 9cb1085..01ff7b2 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -206,6 +206,10 @@ printk(BIOS_WARNING, "SF: Erase offset/length not multiple of erase size\n"); return -1; } + if (len == 0) { + printk(BIOS_WARNING, "Erase length cannot be 0\n"); + return -1; + }
cmd[0] = flash->erase_cmd; start = offset;