tpm: check for TPM_CHIP_FLAG_TPM2 before calling tpm2_shutdown()
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 25 Apr 2016 09:20:07 +0000 (12:20 +0300)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 25 Jun 2016 14:26:35 +0000 (17:26 +0300)
Fixes: 20e0152393b41 ("tpm: fix crash in tpm_tis deinitialization")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reported-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
drivers/char/tpm/tpm-chip.c

index 5bc530c..2ea2f15 100644 (file)
@@ -269,7 +269,8 @@ static void tpm_del_char_device(struct tpm_chip *chip)
 
        /* Make the driver uncallable. */
        down_write(&chip->ops_sem);
-       tpm2_shutdown(chip, TPM2_SU_CLEAR);
+       if (chip->flags & TPM_CHIP_FLAG_TPM2)
+               tpm2_shutdown(chip, TPM2_SU_CLEAR);
        chip->ops = NULL;
        up_write(&chip->ops_sem);
 }