summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/spi/spi_flash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 9cb10855fa..f2714791db 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -206,6 +206,10 @@ int spi_flash_cmd_erase(const struct spi_flash *flash, u32 offset, size_t len)
printk(BIOS_WARNING, "SF: Erase offset/length not multiple of erase size\n");
return -1;
}
+ if (len == 0) {
+ printk(BIOS_WARNING, "SF: Erase length cannot be 0\n");
+ return -1;
+ }
cmd[0] = flash->erase_cmd;
start = offset;