Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4eadfaf authored by Christophe Ricard's avatar Christophe Ricard Committed by Peter Huewe
Browse files

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



Add a return value check when reading data from the FIFO register.

Cc: <stable@vger.kernel.org>
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>
parent aec04cbd
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -441,7 +441,7 @@ again:
 */
 */
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 tpm_stm_dev *tpm_dev;
	struct tpm_stm_dev *tpm_dev;


	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
@@ -455,7 +455,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(tpm_dev, TPM_DATA_FIFO, buf + size, len);
		ret = I2C_READ_DATA(tpm_dev, TPM_DATA_FIFO, buf + size, len);
		if (ret < 0)
			return ret;

		size += len;
		size += len;
	}
	}
	return size;
	return size;