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 <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/406516
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
Vadim Bendebury
2016-11-02 10:59:46 -07:00
committed by chrome-bot
parent 6a2f9c5a58
commit d28b4e1444

View File

@@ -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); response = tpm_process_command(TPM2_NV_Write, &nv_writec);
/* Need to map tpm error codes into internal values. */ /* Need to map tpm error codes into internal values. */
if (!response) if (!response || response->hdr.tpm_code)
return TPM_E_WRITE_FAILURE; return TPM_E_WRITE_FAILURE;
return TPM_SUCCESS; return TPM_SUCCESS;
@@ -472,7 +472,7 @@ uint32_t TlclWriteLock(uint32_t index)
response = tpm_process_command(TPM2_NV_WriteLock, &nv_writelockc); response = tpm_process_command(TPM2_NV_WriteLock, &nv_writelockc);
/* Need to map tpm error codes into internal values. */ /* Need to map tpm error codes into internal values. */
if (!response) if (!response || response->hdr.tpm_code)
return TPM_E_WRITE_FAILURE; return TPM_E_WRITE_FAILURE;
return TPM_SUCCESS; return TPM_SUCCESS;
@@ -490,7 +490,7 @@ uint32_t TlclReadLock(uint32_t index)
response = tpm_process_command(TPM2_NV_ReadLock, &nv_readlockc); response = tpm_process_command(TPM2_NV_ReadLock, &nv_readlockc);
/* Need to map tpm error codes into internal values. */ /* Need to map tpm error codes into internal values. */
if (!response) if (!response || response->hdr.tpm_code)
return TPM_E_READ_FAILURE; return TPM_E_READ_FAILURE;
return TPM_SUCCESS; return TPM_SUCCESS;