Skip to content

Commit ed9be0e

Browse files
linosanfilippo-kunbusjarkkojs
authored andcommitted
tpm, tpm_tis: Do not skip reset of original interrupt vector
If in tpm_tis_probe_irq_single() an error occurs after the original interrupt vector has been read, restore the interrupts before the error is returned. Since the caller does not check the error value, return -1 in any case that the TPM_CHIP_FLAG_IRQ flag is not set. Since the return value of function tpm_tis_gen_interrupt() is not longer used, make it a void function. Fixes: 1107d06 ("tpm_tis: Introduce intermediate layer for TPM access") Signed-off-by: Lino Sanfilippo <[email protected]> Tested-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 6d789ad commit ed9be0e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
733733
return IRQ_HANDLED;
734734
}
735735

736-
static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
736+
static void tpm_tis_gen_interrupt(struct tpm_chip *chip)
737737
{
738738
const char *desc = "attempting to generate an interrupt";
739739
u32 cap2;
@@ -742,16 +742,14 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
742742

743743
ret = request_locality(chip, 0);
744744
if (ret < 0)
745-
return ret;
745+
return;
746746

747747
if (chip->flags & TPM_CHIP_FLAG_TPM2)
748748
ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
749749
else
750750
ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
751751

752752
release_locality(chip, 0);
753-
754-
return ret;
755753
}
756754

757755
/* Register the IRQ and issue a command that will cause an interrupt. If an
@@ -781,42 +779,37 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
781779

782780
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
783781
if (rc < 0)
784-
return rc;
782+
goto restore_irqs;
785783

786784
rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &int_status);
787785
if (rc < 0)
788-
return rc;
786+
goto restore_irqs;
789787

790788
/* Clear all existing */
791789
rc = tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), int_status);
792790
if (rc < 0)
793-
return rc;
794-
791+
goto restore_irqs;
795792
/* Turn on */
796793
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality),
797794
intmask | TPM_GLOBAL_INT_ENABLE);
798795
if (rc < 0)
799-
return rc;
796+
goto restore_irqs;
800797

801798
clear_bit(TPM_TIS_IRQ_TESTED, &priv->flags);
802799

803800
/* Generate an interrupt by having the core call through to
804801
* tpm_tis_send
805802
*/
806-
rc = tpm_tis_gen_interrupt(chip);
807-
if (rc < 0)
808-
return rc;
803+
tpm_tis_gen_interrupt(chip);
809804

805+
restore_irqs:
810806
/* tpm_tis_send will either confirm the interrupt is working or it
811807
* will call disable_irq which undoes all of the above.
812808
*/
813809
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
814-
rc = tpm_tis_write8(priv, original_int_vec,
815-
TPM_INT_VECTOR(priv->locality));
816-
if (rc < 0)
817-
return rc;
818-
819-
return 1;
810+
tpm_tis_write8(priv, original_int_vec,
811+
TPM_INT_VECTOR(priv->locality));
812+
return -1;
820813
}
821814

822815
return 0;

0 commit comments

Comments
 (0)