From d28b4e1444372e709729787be6e81490e46c202d Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Wed, 2 Nov 2016 10:59:46 -0700 Subject: [PATCH] tpm2_lite: do not ignore errors reported by TPM Some tpm command wrappers ignore TPM return code, they should not report success in case TPM operation failed. BRANCH=none BUG=chrome-os-partner:55668 TEST=verified that tpmc on reef does not silently ignore tpm write errors any more. Change-Id: Id8955e3757948a3fd0972f88b569fb8828be7715 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/406516 Commit-Ready: Andrey Pronin Reviewed-by: Bill Richardson --- firmware/lib/tpm2_lite/tlcl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/lib/tpm2_lite/tlcl.c b/firmware/lib/tpm2_lite/tlcl.c index 3b4ba48055..e4f3b53b31 100644 --- a/firmware/lib/tpm2_lite/tlcl.c +++ b/firmware/lib/tpm2_lite/tlcl.c @@ -448,7 +448,7 @@ uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length) response = tpm_process_command(TPM2_NV_Write, &nv_writec); /* Need to map tpm error codes into internal values. */ - if (!response) + if (!response || response->hdr.tpm_code) return TPM_E_WRITE_FAILURE; return TPM_SUCCESS; @@ -472,7 +472,7 @@ uint32_t TlclWriteLock(uint32_t index) response = tpm_process_command(TPM2_NV_WriteLock, &nv_writelockc); /* Need to map tpm error codes into internal values. */ - if (!response) + if (!response || response->hdr.tpm_code) return TPM_E_WRITE_FAILURE; return TPM_SUCCESS; @@ -490,7 +490,7 @@ uint32_t TlclReadLock(uint32_t index) response = tpm_process_command(TPM2_NV_ReadLock, &nv_readlockc); /* Need to map tpm error codes into internal values. */ - if (!response) + if (!response || response->hdr.tpm_code) return TPM_E_READ_FAILURE; return TPM_SUCCESS;