Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965415AbdDSPap (ORCPT ); Wed, 19 Apr 2017 11:30:45 -0400 Received: from mga06.intel.com ([134.134.136.31]:11454 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937560AbdDSPaj (ORCPT ); Wed, 19 Apr 2017 11:30:39 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,221,1488873600"; d="scan'208";a="847669295" Date: Wed, 19 Apr 2017 18:30:36 +0300 From: Jarkko Sakkinen To: Stefan Berger Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, jgunthorpe@obsidianresearch.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tpm: Fix reference count to main device Message-ID: <20170419153036.7bcax775wskrskdo@intel.com> References: <1492480706-6928-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1492480706-6928-1-git-send-email-stefanb@linux.vnet.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1407 Lines: 40 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") > Signed-off-by: Stefan Berger 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 > > --- > 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 >