]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure
authorAlper Ak <alperyasinak1@gmail.com>
Fri, 26 Dec 2025 10:23:38 +0000 (13:23 +0300)
committerJarkko Sakkinen <jarkko@kernel.org>
Tue, 3 Feb 2026 00:36:32 +0000 (02:36 +0200)
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>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm_i2c_infineon.c

index bdf1f329a67946144fb6ec6bc79e12d87f42ac12..8b7d32de0b2ef995b359d066f1c9f772c300b758 100644 (file)
@@ -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;