On Thu, Aug 13, 2026 at 11:30:31PM +0800, Ruoyu Wang wrote:
> st33zp24_status() ignores the result of the transport read and returns
> data even when no byte was received. The I2C transport, for example,
> skips i2c_master_recv() when the register-select write is short or fails,
> leaving data uninitialized. The resulting stack value can be interpreted
> as TPM_STS flags and let status checks complete spuriously.
>
> The status callback cannot propagate a transport error. Return zero
> unless recv() reports exactly one byte. With no status bits set, callers
> retry or take their existing timeout or error path instead of acting on
> an invalid status value.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: 251a7b08213a ("TPM: STMicroelectronics ST33 I2C KERNEL 3.x")
> Signed-off-by: Ruoyu Wang <[email protected]>
> ---
> drivers/char/tpm/st33zp24/st33zp24.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/st33zp24/st33zp24.c
> b/drivers/char/tpm/st33zp24/st33zp24.c
> index e2b7451ea7ccd3..898e8d01d26698 100644
> --- a/drivers/char/tpm/st33zp24/st33zp24.c
> +++ b/drivers/char/tpm/st33zp24/st33zp24.c
> @@ -93,7 +93,9 @@ static u8 st33zp24_status(struct tpm_chip *chip)
> struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
> u8 data;
>
> - tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1);
> + if (tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1) != 1)
> + return 0;
> +
> return data;
> }
>
> --
> 2.51.0
>
Reviewed-by: Jarkko Sakkinen <[email protected]>
thanks
BR, Jarkko