Skip to content

Commit a036688

Browse files
cricard13sashalevin
authored andcommitted
tpm/tpm_i2c_stm_st33: Add status check when reading data on the FIFO
[ Upstream commit c4eadfa ] Add a return value check when reading data from the FIFO register. Cc: <stable@vger.kernel.org> Reviewed-by: Jason Gunthorpe <jason.gunthorpe@obsidianresearch.com> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Reviewed-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 33c5b3a commit a036688

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎drivers/char/tpm/tpm_i2c_stm_st33.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
397397
*/
398398
static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
399399
{
400-
int size = 0, burstcnt, len;
400+
int size = 0, burstcnt, len, ret;
401401
struct i2c_client *client;
402402

403403
client = (struct i2c_client *)TPM_VPRIV(chip);
@@ -406,13 +406,15 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
406406
wait_for_stat(chip,
407407
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
408408
chip->vendor.timeout_c,
409-
&chip->vendor.read_queue)
410-
== 0) {
409+
&chip->vendor.read_queue) == 0) {
411410
burstcnt = get_burstcount(chip);
412411
if (burstcnt < 0)
413412
return burstcnt;
414413
len = min_t(int, burstcnt, count - size);
415-
I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
414+
ret = I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
415+
if (ret < 0)
416+
return ret;
417+
416418
size += len;
417419
}
418420
return size;

0 commit comments

Comments
 (0)