From 8aba3cbf84225a5bc666a071c84758328ca87e76 Mon Sep 17 00:00:00 2001 From: Claudio Carvalho Date: Mon, 28 Nov 2016 01:08:13 -0200 Subject: tpm_i2c_nuvoton: handle errors after reading the tpm fifo This adds code to handle errors after reading the tpm fifo in tpm_read_fifo(). Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho Signed-off-by: Stewart Smith --- libstb/drivers/tpm_i2c_nuvoton.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libstb/drivers') diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c index a4cc371..f39ca9c 100644 --- a/libstb/drivers/tpm_i2c_nuvoton.c +++ b/libstb/drivers/tpm_i2c_nuvoton.c @@ -389,8 +389,18 @@ static int tpm_read_fifo(uint8_t* buf, size_t* buflen) count += burst_count; DBG("%s FIFO: %d bytes read, count=%zd, rc=%d\n", (rc) ? "!!!!" : "----", burst_count, count, rc); - if (rc < 0) + if (rc < 0) { + /** + * @fwts-label TPMReadFifo + * @fwts-advice Either the tpm device or the tpm-i2c interface + * doesn't seem to be working properly. Check the return code + * (rc) for further details. + */ + prlog(PR_ERR, "NUVOTON: fail to read fifo, count=%zd, " + "rc=%d\n", count, rc); + rc = STB_DRIVER_ERROR; goto error; + } rc = tpm_wait_for_fifo_status( TPM_STS_VALID | TPM_STS_DATA_AVAIL, TPM_STS_VALID | TPM_STS_DATA_AVAIL); -- cgit v1.1