[coreboot-gerrit] New patch to review for coreboot: tpm2: fix tpm_write() error reporting

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Tue Jul 12 22:06:37 CEST 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15637

-gerrit

commit 283e212108cbaa5780ac98d9d8515e1d1429943e
Author: Vadim Bendebury <vbendeb at chromium.org>
Date:   Tue Jul 5 22:30:16 2016 -0700

    tpm2: fix tpm_write() error reporting
    
    The code misses the cases when a response was received but the command
    failed. This patch fixes the problem.
    
    BRANCH=none
    BUG=chrome-os-partner:50645
    TEST=none
    
    Change-Id: I3d50a4b67e3592bb80d2524a7c7f264fddbd34ae
    Signed-off-by: Martin Roth <martinroth at chromium.org>
    Original-Commit-Id: 8f4d6185e13beead7156027e1cb40f7944e46569
    Original-Change-Id: I914ab6509d3ab2082152652205802201a6637fcc
    Original-Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/358096
    Original-Reviewed-by: Aaron Durbin <adurbin at chromium.org>
---
 src/lib/tpm2_tlcl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/lib/tpm2_tlcl.c b/src/lib/tpm2_tlcl.c
index ec20ca9..312fe36 100644
--- a/src/lib/tpm2_tlcl.c
+++ b/src/lib/tpm2_tlcl.c
@@ -246,13 +246,13 @@ uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length)
 
 	response = tpm_process_command(TPM2_NV_Write, &nv_writec);
 
+	printk(BIOS_INFO, "%s: response is %x\n",
+	       __func__, response ? response->hdr.tpm_code : -1);
+
 	/* Need to map tpm error codes into internal values. */
-	if (!response)
+	if (!response || response->hdr.tpm_code)
 		return TPM_E_WRITE_FAILURE;
 
-	printk(BIOS_INFO, "%s:%d return code %x\n", __func__, __LINE__,
-	       response->hdr.tpm_code);
-
 	return TPM_SUCCESS;
 }
 



More information about the coreboot-gerrit mailing list