* [PATCH] tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure
@ 2025-12-26 10:23 Alper Ak
2026-01-02 17:17 ` Jarkko Sakkinen
0 siblings, 1 reply; 2+ messages in thread
From: Alper Ak @ 2025-12-26 10:23 UTC (permalink / raw)
To: peterhuewe, jarkko
Cc: Alper Ak, Jason Gunthorpe, Bryan Freed, Andi Shyti, Kent Yoder,
Marcel Selhorst, linux-integrity, linux-kernel
get_burstcount() can return -EBUSY on timeout. When this happens, the
function returns directly without releasing the locality that was
acquired at the beginning of tpm_tis_i2c_send().
Use goto out_err to ensure proper cleanup when get_burstcount() fails.
Fixes: aad628c1d91a ("char/tpm: Add new driver for Infineon I2C TIS TPM")
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
drivers/char/tpm/tpm_i2c_infineon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index bdf1f329a679..8b7d32de0b2e 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -544,8 +544,10 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
burstcnt = get_burstcount(chip);
/* burstcnt < 0 = TPM is busy */
- if (burstcnt < 0)
- return burstcnt;
+ if (burstcnt < 0) {
+ rc = burstcnt;
+ goto out_err;
+ }
if (burstcnt > (len - 1 - count))
burstcnt = len - 1 - count;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure
2025-12-26 10:23 [PATCH] tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure Alper Ak
@ 2026-01-02 17:17 ` Jarkko Sakkinen
0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2026-01-02 17:17 UTC (permalink / raw)
To: Alper Ak
Cc: peterhuewe, Jason Gunthorpe, Bryan Freed, Andi Shyti, Kent Yoder,
Marcel Selhorst, linux-integrity, linux-kernel
On Fri, Dec 26, 2025 at 01:23:38PM +0300, Alper Ak wrote:
> get_burstcount() can return -EBUSY on timeout. When this happens, the
> function returns directly without releasing the locality that was
> acquired at the beginning of tpm_tis_i2c_send().
>
> Use goto out_err to ensure proper cleanup when get_burstcount() fails.
>
> Fixes: aad628c1d91a ("char/tpm: Add new driver for Infineon I2C TIS TPM")
> Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
> ---
> drivers/char/tpm/tpm_i2c_infineon.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
> index bdf1f329a679..8b7d32de0b2e 100644
> --- a/drivers/char/tpm/tpm_i2c_infineon.c
> +++ b/drivers/char/tpm/tpm_i2c_infineon.c
> @@ -544,8 +544,10 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
> burstcnt = get_burstcount(chip);
>
> /* burstcnt < 0 = TPM is busy */
> - if (burstcnt < 0)
> - return burstcnt;
> + if (burstcnt < 0) {
> + rc = burstcnt;
> + goto out_err;
> + }
>
> if (burstcnt > (len - 1 - count))
> burstcnt = len - 1 - count;
> --
> 2.43.0
>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-02 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-26 10:23 [PATCH] tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure Alper Ak
2026-01-02 17:17 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox