From 3ddeae3899a3119ed09096bafa945f788650daba Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Mon, 27 Mar 2017 17:04:26 -0500 Subject: [PATCH] UPSTREAM: drivers/spi/tpm: honor tis_sendrecv() API The spi tis_sendrecv() implementation was always returning success for all transactions. Correct this by returning -1 on error when tpm2_process_command() returns 0 since that's its current failure return code. BUG=b:36598499 Change-Id: I614d05e76f8f09e071405b1acdc68db6ab989976 Signed-off-by: Patrick Georgi Original-Commit-Id: 6ef52cd7519d0166382bb7743de6fd34c6c6436d Original-Change-Id: I8bfb5a09198ae4c293330e770271773a185d5061 Original-Signed-off-by: Aaron Durbin Original-Reviewed-on: https://review.coreboot.org/19058 Original-Reviewed-by: Furquan Shaikh Original-Tested-by: build bot (Jenkins) Reviewed-on: https://chromium-review.googlesource.com/466053 --- src/drivers/spi/tpm/tis.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/drivers/spi/tpm/tis.c b/src/drivers/spi/tpm/tis.c index d3c727cb27..481c9da1d0 100644 --- a/src/drivers/spi/tpm/tis.c +++ b/src/drivers/spi/tpm/tis.c @@ -85,6 +85,11 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, uint8_t *recvbuf, size_t *rbuf_len) { int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len); + + if (len == 0) + return -1; + *rbuf_len = len; + return 0; }