summaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm-chip.c
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2017-04-18 03:58:26 +0200
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2017-04-24 23:27:18 +0200
commit8979b02aaf1d6de8d52cc143aa4da961ed32e5a2 (patch)
tree2b6485a03914ec7d0a35853486b2ee4d4b07c883 /drivers/char/tpm/tpm-chip.c
parenttpm_tis: convert to using locality callbacks (diff)
downloadlinux-8979b02aaf1d6de8d52cc143aa4da961ed32e5a2.tar.xz
linux-8979b02aaf1d6de8d52cc143aa4da961ed32e5a2.zip
tpm: Fix reference count to main device
The main device is currently not properly released due to one additional reference to the 'devs' device which is only released in case of a TPM 2. So, also get the additional reference only in case of a TPM2. Fixes: fdc915f7f719 ("tpm: expose spaces via a device link /dev/tpmrm<n>") Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm/tpm-chip.c')
-rw-r--r--drivers/char/tpm/tpm-chip.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index a321bd57f3e9..9dec9f551b83 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -191,9 +191,10 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
/* get extra reference on main device to hold on
* behalf of devs. This holds the chip structure
* while cdevs is in use. The corresponding put
- * is in the tpm_devs_release
+ * is in the tpm_devs_release (TPM2 only)
*/
- get_device(&chip->dev);
+ if (chip->flags & TPM_CHIP_FLAG_TPM2)
+ get_device(&chip->dev);
if (chip->dev_num == 0)
chip->dev.devt = MKDEV(MISC_MAJOR, TPM_MINOR);