Skip to content

Commit 8979b02

Browse files
stefanbergerJarkko Sakkinen
authored and
Jarkko Sakkinen
committed
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: fdc915f ("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>
1 parent e6aef06 commit 8979b02

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/char/tpm/tpm-chip.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
191191
/* get extra reference on main device to hold on
192192
* behalf of devs. This holds the chip structure
193193
* while cdevs is in use. The corresponding put
194-
* is in the tpm_devs_release
194+
* is in the tpm_devs_release (TPM2 only)
195195
*/
196-
get_device(&chip->dev);
196+
if (chip->flags & TPM_CHIP_FLAG_TPM2)
197+
get_device(&chip->dev);
197198

198199
if (chip->dev_num == 0)
199200
chip->dev.devt = MKDEV(MISC_MAJOR, TPM_MINOR);

0 commit comments

Comments
 (0)