<p>Richard Spiegel has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/27995">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">drivers/i2c/tpm/cr50.c: Check if TPM was read<br><br>Under some conditions, cr50_i2c_read() can return without actually reading<br>the TPM, which will leave access uninitialized. Set an initial value for<br>access, and if TPM fails to respond in time check if at least TPM was read.<br>This way avoids printing an uninitialized value.<br><br>BUG=b:112253891<br>TEST=Build and boot grunt.<br><br>Change-Id: I5ec7a99396db32971dc8485b77158d735ab1d788<br>Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com><br>---<br>M src/drivers/i2c/tpm/cr50.c<br>1 file changed, 7 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/95/27995/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c</span><br><span>index 3c2f5bd..036be42 100644</span><br><span>--- a/src/drivers/i2c/tpm/cr50.c</span><br><span>+++ b/src/drivers/i2c/tpm/cr50.c</span><br><span>@@ -181,7 +181,7 @@</span><br><span> static int process_reset(struct tpm_chip *chip)</span><br><span> {</span><br><span>         struct stopwatch sw;</span><br><span style="color: hsl(0, 100%, 40%);">-    uint8_t access;</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t access = 0xff;</span><br><span> </span><br><span>   /*</span><br><span>    * Locality is released by TPM reset.</span><br><span>@@ -214,9 +214,12 @@</span><br><span>                 return 0;</span><br><span>    } while (!stopwatch_expired(&sw));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      printk(BIOS_ERR,</span><br><span style="color: hsl(0, 100%, 40%);">-               "TPM failed to reset after %ld ms, status: %#x\n",</span><br><span style="color: hsl(0, 100%, 40%);">-            stopwatch_duration_msecs(&sw), access);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (access == 0xff)</span><br><span style="color: hsl(120, 100%, 40%);">+           printk(BIOS_ERR, "Failed to read TPM\n");</span><br><span style="color: hsl(120, 100%, 40%);">+   else</span><br><span style="color: hsl(120, 100%, 40%);">+          printk(BIOS_ERR,</span><br><span style="color: hsl(120, 100%, 40%);">+                      "TPM failed to reset after %ld ms, status: %#x\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                  stopwatch_duration_msecs(&sw), access);</span><br><span> </span><br><span>      return -1;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/27995">change 27995</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/27995"/><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: I5ec7a99396db32971dc8485b77158d735ab1d788 </div>
<div style="display:none"> Gerrit-Change-Number: 27995 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Spiegel <richard.spiegel@silverbackltd.com> </div>