[coreboot-gerrit] Change in coreboot[master]: drivers/i2c/tpm/cr50.c: Check if TPM was read

Richard Spiegel (Code Review) gerrit at coreboot.org
Thu Aug 9 23:41:48 CEST 2018


Richard Spiegel has uploaded this change for review. ( https://review.coreboot.org/27995


Change subject: drivers/i2c/tpm/cr50.c: Check if TPM was read
......................................................................

drivers/i2c/tpm/cr50.c: Check if TPM was read

Under some conditions, cr50_i2c_read() can return without actually reading
the TPM, which will leave access uninitialized. Set an initial value for
access, and if TPM fails to respond in time check if at least TPM was read.
This way avoids printing an uninitialized value.

BUG=b:112253891
TEST=Build and boot grunt.

Change-Id: I5ec7a99396db32971dc8485b77158d735ab1d788
Signed-off-by: Richard Spiegel <richard.spiegel at silverbackltd.com>
---
M src/drivers/i2c/tpm/cr50.c
1 file changed, 7 insertions(+), 4 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/95/27995/1

diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c
index 3c2f5bd..036be42 100644
--- a/src/drivers/i2c/tpm/cr50.c
+++ b/src/drivers/i2c/tpm/cr50.c
@@ -181,7 +181,7 @@
 static int process_reset(struct tpm_chip *chip)
 {
 	struct stopwatch sw;
-	uint8_t access;
+	uint8_t access = 0xff;
 
 	/*
 	 * Locality is released by TPM reset.
@@ -214,9 +214,12 @@
 		return 0;
 	} while (!stopwatch_expired(&sw));
 
-	printk(BIOS_ERR,
-	       "TPM failed to reset after %ld ms, status: %#x\n",
-	       stopwatch_duration_msecs(&sw), access);
+	if (access == 0xff)
+		printk(BIOS_ERR, "Failed to read TPM\n");
+	else
+		printk(BIOS_ERR,
+			"TPM failed to reset after %ld ms, status: %#x\n",
+			stopwatch_duration_msecs(&sw), access);
 
 	return -1;
 }

-- 
To view, visit https://review.coreboot.org/27995
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: I5ec7a99396db32971dc8485b77158d735ab1d788
Gerrit-Change-Number: 27995
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/20180809/8c7eb09c/attachment.html>


More information about the coreboot-gerrit mailing list