[coreboot-gerrit] Change in coreboot[master]: drivers/spi/spi_flash.c: Check input paarameter

Richard Spiegel (Code Review) gerrit at coreboot.org
Wed Aug 8 01:41:16 CEST 2018


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 at 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;

-- 
To view, visit https://review.coreboot.org/27952
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b5129a15c9e0ea45f4dba4ab0729196cb64699b
Gerrit-Change-Number: 27952
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Spiegel <richard.spiegel at silverbackltd.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180807/945af4c5/attachment.html>


More information about the coreboot-gerrit mailing list