<p>Richard Spiegel has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/27952">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">drivers/spi/spi_flash.c: Check input paarameter<br><br>In procedure spi_flash_cmd_erase(), parameter "len" is not validated and<br>could lead to the return of an invalid (not-initialized) value. Validate<br>the parameter early on.<br><br>BUG=b:112253891<br>TEST=Build and boot grunt.<br><br>Change-Id: I0b5129a15c9e0ea45f4dba4ab0729196cb64699b<br>Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com><br>---<br>M src/drivers/spi/spi_flash.c<br>1 file changed, 4 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/52/27952/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c</span><br><span>index 9cb1085..01ff7b2 100644</span><br><span>--- a/src/drivers/spi/spi_flash.c</span><br><span>+++ b/src/drivers/spi/spi_flash.c</span><br><span>@@ -206,6 +206,10 @@</span><br><span>               printk(BIOS_WARNING, "SF: Erase offset/length not multiple of erase size\n");</span><br><span>              return -1;</span><br><span>   }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (len == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               printk(BIOS_WARNING, "Erase length cannot be 0\n");</span><br><span style="color: hsl(120, 100%, 40%);">+         return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span> </span><br><span>        cmd[0] = flash->erase_cmd;</span><br><span>        start = offset;</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/27952">change 27952</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/27952"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I0b5129a15c9e0ea45f4dba4ab0729196cb64699b </div>
<div style="display:none"> Gerrit-Change-Number: 27952 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Spiegel <richard.spiegel@silverbackltd.com> </div>