linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: Fix reference count to main device
@ 2017-04-18  1:58 Stefan Berger
  2017-04-19 15:30 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Berger @ 2017-04-18  1:58 UTC (permalink / raw)
  To: tpmdd-devel, linux-security-module, James.Bottomley
  Cc: jgunthorpe, jarkko.sakkinen, linux-kernel, Stefan Berger

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>

---
 drivers/char/tpm/tpm-chip.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index a321bd5..9dec9f5 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);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tpm: Fix reference count to main device
  2017-04-18  1:58 [PATCH] tpm: Fix reference count to main device Stefan Berger
@ 2017-04-19 15:30 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2017-04-19 15:30 UTC (permalink / raw)
  To: Stefan Berger
  Cc: tpmdd-devel, linux-security-module, James.Bottomley, jgunthorpe,
	linux-kernel

On Mon, Apr 17, 2017 at 09:58:26PM -0400, Stefan Berger wrote:
> 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>

Excellent, thank you. I'll send this with some other small fixes for
4.12 to James rather sooner than later.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

> 
> ---
>  drivers/char/tpm/tpm-chip.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index a321bd5..9dec9f5 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);
> -- 
> 2.4.3
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-19 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-18  1:58 [PATCH] tpm: Fix reference count to main device Stefan Berger
2017-04-19 15:30 ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).