Skip to content

Commit

Permalink
tpm: Fix reference count to main device
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jarkko Sakkinen <[email protected]>
Tested-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
  • Loading branch information
stefanberger authored and Jarkko Sakkinen committed Apr 24, 2017
1 parent e6aef06 commit 8979b02
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/char/tpm/tpm-chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8979b02

Please sign in to comment.