Skip to content

Commit d62ad89

Browse files
committed
tpm, tpm_tis: Do not skip reset of original interrupt vector
JIRA: https://issues.redhat.com/browse/RHEL-72765 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit ed9be0e Author: Lino Sanfilippo <l.sanfilippo@kunbus.com> Date: Thu Nov 24 14:55:28 2022 +0100 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 <l.sanfilippo@kunbus.com> Tested-by: Jarkko Sakkinen <jarkko@kernel.org> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent eba4e01 commit d62ad89

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
@@ -715,7 +715,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
715715
return IRQ_HANDLED;
716716
}
717717

718-
static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
718+
static void tpm_tis_gen_interrupt(struct tpm_chip *chip)
719719
{
720720
const char *desc = "attempting to generate an interrupt";
721721
u32 cap2;
@@ -724,16 +724,14 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
724724

725725
ret = request_locality(chip, 0);
726726
if (ret < 0)
727-
return ret;
727+
return;
728728

729729
if (chip->flags & TPM_CHIP_FLAG_TPM2)
730730
ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
731731
else
732732
ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
733733

734734
release_locality(chip, 0);
735-
736-
return ret;
737735
}
738736

739737
/* Register the IRQ and issue a command that will cause an interrupt. If an
@@ -763,42 +761,37 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
763761

764762
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
765763
if (rc < 0)
766-
return rc;
764+
goto restore_irqs;
767765

768766
rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &int_status);
769767
if (rc < 0)
770-
return rc;
768+
goto restore_irqs;
771769

772770
/* Clear all existing */
773771
rc = tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), int_status);
774772
if (rc < 0)
775-
return rc;
776-
773+
goto restore_irqs;
777774
/* Turn on */
778775
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality),
779776
intmask | TPM_GLOBAL_INT_ENABLE);
780777
if (rc < 0)
781-
return rc;
778+
goto restore_irqs;
782779

783780
clear_bit(TPM_TIS_IRQ_TESTED, &priv->flags);
784781

785782
/* Generate an interrupt by having the core call through to
786783
* tpm_tis_send
787784
*/
788-
rc = tpm_tis_gen_interrupt(chip);
789-
if (rc < 0)
790-
return rc;
785+
tpm_tis_gen_interrupt(chip);
791786

787+
restore_irqs:
792788
/* tpm_tis_send will either confirm the interrupt is working or it
793789
* will call disable_irq which undoes all of the above.
794790
*/
795791
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
796-
rc = tpm_tis_write8(priv, original_int_vec,
797-
TPM_INT_VECTOR(priv->locality));
798-
if (rc < 0)
799-
return rc;
800-
801-
return 1;
792+
tpm_tis_write8(priv, original_int_vec,
793+
TPM_INT_VECTOR(priv->locality));
794+
return -1;
802795
}
803796

804797
return 0;

0 commit comments

Comments
 (0)