summaryrefslogtreecommitdiff
path: root/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/security/tpm/tss/tcg-2.0/tss_marshaling.c')
-rw-r--r--src/security/tpm/tss/tcg-2.0/tss_marshaling.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
index a229dd17ef..eff1acd2cd 100644
--- a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
+++ b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
@@ -587,17 +587,23 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command, struct ibuf *ib)
if (rc != 0)
return NULL;
- if (ibuf_remaining(ib) == 0) {
- if (tpm2_static_resp.hdr.tpm_size != ibuf_nr_read(ib))
- printk(BIOS_ERR,
- "%s: size mismatch in response to command %#x\n",
- __func__, command);
- return &tpm2_static_resp;
+ if (ibuf_capacity(ib) != tpm2_static_resp.hdr.tpm_size) {
+ printk(BIOS_ERR,
+ "%s: size mismatch in response to command %#x\n",
+ __func__, command);
+ return NULL;
}
+ /* On errors, we're not sure what the TPM is returning. None of the
+ commands we use actually expect useful data payloads for errors, so
+ just ignore any data after the header. */
+ if (tpm2_static_resp.hdr.tpm_code != TPM2_RC_SUCCESS)
+ return &tpm2_static_resp;
+
switch (command) {
case TPM2_Startup:
case TPM2_Shutdown:
+ case TPM2_SelfTest:
break;
case TPM2_GetCapability: