Skip to content

Commit 20e0152

Browse files
author
Jarkko Sakkinen
committed
tpm: fix crash in tpm_tis deinitialization
rmmod crashes the driver because tpm_chip_unregister() already sets ops to NULL. This commit fixes the issue by moving tpm2_shutdown() to tpm_chip_unregister(). This commit is also cleanup because it removes duplicate code from tpm_crb and tpm_tis to the core. Fixes: 4d3eac5 ("tpm: Provide strong locking for device removal") Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
1 parent 559fbb4 commit 20e0152

File tree

4 files changed

+1
-7
lines changed

4 files changed

+1
-7
lines changed

drivers/char/tpm/tpm-chip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ static void tpm_del_char_device(struct tpm_chip *chip)
269269

270270
/* Make the driver uncallable. */
271271
down_write(&chip->ops_sem);
272+
tpm2_shutdown(chip, TPM2_SU_CLEAR);
272273
chip->ops = NULL;
273274
up_write(&chip->ops_sem);
274275
}

drivers/char/tpm/tpm2-cmd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type)
773773
dev_warn(&chip->dev, "transmit returned %d while stopping the TPM",
774774
rc);
775775
}
776-
EXPORT_SYMBOL_GPL(tpm2_shutdown);
777776

778777
/*
779778
* tpm2_calc_ordinal_duration() - maximum duration for a command

drivers/char/tpm/tpm_crb.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,6 @@ static int crb_acpi_remove(struct acpi_device *device)
344344
struct device *dev = &device->dev;
345345
struct tpm_chip *chip = dev_get_drvdata(dev);
346346

347-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
348-
tpm2_shutdown(chip, TPM2_SU_CLEAR);
349-
350347
tpm_chip_unregister(chip);
351348

352349
return 0;

drivers/char/tpm/tpm_tis.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,6 @@ static void tpm_tis_remove(struct tpm_chip *chip)
653653
void __iomem *reg = chip->vendor.iobase +
654654
TPM_INT_ENABLE(chip->vendor.locality);
655655

656-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
657-
tpm2_shutdown(chip, TPM2_SU_CLEAR);
658-
659656
iowrite32(~TPM_GLOBAL_INT_ENABLE & ioread32(reg), reg);
660657
release_locality(chip, chip->vendor.locality, 1);
661658
}

0 commit comments

Comments
 (0)