Skip to contentSkip to conversation

tpm: tpm_i2c_nuvoton: disable IRQ on wait timeout

PATCH In review Myeonghun Pak 2 participants 2 messages Jun 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: tpm_i2c_nuvoton: disable IRQ on wait timeout

i2c_nuvoton_wait_for_stat() enables the IRQ before waiting for the interrupt handler to report a status change. If the wait times out, or is interrupted before the handler runs, the function returns without balancing the enable_irq() call.

Disable the IRQ before leaving the failed wait path. Also preserve an interrupted wait's original error code instead of converting it to -ETIMEDOUT inside the helper.

Fixes 4c336e4b1556 ("tpm: Add support for the Nuvoton NPCT501 I2C TPM")
---
 drivers/char/tpm/tpm_i2c_nuvoton.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_i2c_nuvoton.c +4 -2
index d44903b..aa36730 100644
@@ -182,8 +182,10 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
 						      timeout);
 		if (rc > 0)
 			return 0;
-		/* At this point we know that the SINT pin is asserted, so we
-		 * do not need to do i2c_nuvoton_check_status */
+
+		disable_irq(priv->irq);
+		if (rc < 0)
+			return rc;
 	} else {
 		unsigned long ten_msec, stop;
 		bool status_valid;
Signature · 1 line
2.47.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Myeonghun Pak

i2c_nuvoton_wait_for_stat() enables the IRQ before waiting for the interrupt handler to report a status change. If the wait times out, or is interrupted before the handler runs, the function returns without balancing the enable_irq() call.

Disable the IRQ before leaving the failed wait path. Also preserve an interrupted wait's original error code instead of converting it to -ETIMEDOUT inside the helper.

Fixes 4c336e4b1556 ("tpm: Add support for the Nuvoton NPCT501 I2C TPM")
---
 drivers/char/tpm/tpm_i2c_nuvoton.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_i2c_nuvoton.c +4 -2
index d44903b..aa36730 100644
@@ -182,8 +182,10 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
 						      timeout);
 		if (rc > 0)
 			return 0;
-		/* At this point we know that the SINT pin is asserted, so we
-		 * do not need to do i2c_nuvoton_check_status */
+
+		disable_irq(priv->irq);
+		if (rc < 0)
+			return rc;
 	} else {
 		unsigned long ten_msec, stop;
 		bool status_valid;
Signature · 1 line
2.47.1

LGTM

BR, Jarkko