Commit 35af27a3 authored by Christophe Ricard's avatar Christophe Ricard Committed by Luis Henriques

tpm/tpm_i2c_stm_st33: Add status check when reading data on the FIFO

commit c4eadfaf upstream.

Add a return value check when reading data from the FIFO register.
Reviewed-by: default avatarJason Gunthorpe <jason.gunthorpe@obsidianresearch.com>
Signed-off-by: default avatarChristophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: default avatarPeter Huewe <peterhuewe@gmx.de>
Signed-off-by: default avatarPeter Huewe <peterhuewe@gmx.de>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 5117c89f
...@@ -397,7 +397,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, ...@@ -397,7 +397,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
*/ */
static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
{ {
int size = 0, burstcnt, len; int size = 0, burstcnt, len, ret;
struct i2c_client *client; struct i2c_client *client;
client = (struct i2c_client *)TPM_VPRIV(chip); client = (struct i2c_client *)TPM_VPRIV(chip);
...@@ -412,7 +412,10 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -412,7 +412,10 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
if (burstcnt < 0) if (burstcnt < 0)
return burstcnt; return burstcnt;
len = min_t(int, burstcnt, count - size); len = min_t(int, burstcnt, count - size);
I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len); ret = I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
if (ret < 0)
return ret;
size += len; size += len;
} }
return size; return size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment