<p>Richard Spiegel has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23827">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/amdfwtool/amdfwtool.c: Check fstat return<br><br>Funtion fstat will return -1 if there's any error, 0 if successful.<br>Check that fstat return is equal to 0, print error message and exit if<br>not 0.<br><br>This fixes CIDs 1353018 and 1353020<br><br>BUG=b:72062481<br>TEST=Build no errors<br><br>Change-Id: I83284d9125c75a29471f213f88b9181d5edba2e6<br>Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com><br>---<br>M util/amdfwtool/amdfwtool.c<br>1 file changed, 10 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/23827/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c</span><br><span>index 303a31d..406ae05 100644</span><br><span>--- a/util/amdfwtool/amdfwtool.c</span><br><span>+++ b/util/amdfwtool/amdfwtool.c</span><br><span>@@ -298,7 +298,11 @@</span><br><span>                          free(base);</span><br><span>                          exit(1);</span><br><span>                     }</span><br><span style="color: hsl(0, 100%, 40%);">-                       fstat(fd, &fd_stat);</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (fstat(fd, &fd_stat)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                printf("fstat error: %s\n", strerror(errno));</span><br><span style="color: hsl(120, 100%, 40%);">+                               free(base);</span><br><span style="color: hsl(120, 100%, 40%);">+                           exit(1);</span><br><span style="color: hsl(120, 100%, 40%);">+                      }</span><br><span> </span><br><span>                        switch (fw_table[i].type) {</span><br><span>                  case AMD_FW_IMC:</span><br><span>@@ -369,7 +373,11 @@</span><br><span>                              free(base);</span><br><span>                          exit(1);</span><br><span>                     }</span><br><span style="color: hsl(0, 100%, 40%);">-                       fstat(fd, &fd_stat);</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (fstat(fd, &fd_stat)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                printf("fstat error: %s\n", strerror(errno));</span><br><span style="color: hsl(120, 100%, 40%);">+                               free(base);</span><br><span style="color: hsl(120, 100%, 40%);">+                           exit(1);</span><br><span style="color: hsl(120, 100%, 40%);">+                      }</span><br><span>                    pspdir[4+4*i+1] = (uint32_t)fd_stat.st_size;</span><br><span> </span><br><span>                     pspdir[4+4*i+2] = pos + rom_base_address;</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23827">change 23827</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/23827"/><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: I83284d9125c75a29471f213f88b9181d5edba2e6 </div>
<div style="display:none"> Gerrit-Change-Number: 23827 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Spiegel <richard.spiegel@silverbackltd.com> </div>