]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tpm: Fix reference count to main device
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 18 Apr 2017 01:58:26 +0000 (21:58 -0400)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 24 Apr 2017 21:27:18 +0000 (00:27 +0300)
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>
drivers/char/tpm/tpm-chip.c

index a321bd57f3e9b69d0b204ed61cb2070008ff87a9..9dec9f551b831496024b98eb8f6e1bff7ed4958b 100644 (file)
@@ -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);