From: Jarkko Sakkinen Subject: Re: [PATCH] tpm: Use the right clean up after cdev_add completes Date: Fri, 24 Feb 2017 23:11:26 +0200 Message-ID: <20170224211126.k3aydrybsvgqqicj@intel.com> References: <20170223211914.GA12752@obsidianresearch.com> <20170224174354.w5e2v3nxntod72je@intel.com> <20170224205949.u63xb5qhqzd7lqtp@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20170224205949.u63xb5qhqzd7lqtp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Jason Gunthorpe Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: tpmdd-devel@lists.sourceforge.net On Fri, Feb 24, 2017 at 10:59:49PM +0200, Jarkko Sakkinen wrote: > On Fri, Feb 24, 2017 at 07:43:54PM +0200, Jarkko Sakkinen wrote: > > On Thu, Feb 23, 2017 at 02:19:14PM -0700, Jason Gunthorpe wrote: > > > Once cdev_add is done the device node is visible to user space and > > > could have been opened. Thus we have to go through the locking > > > process in tpm_del_char_device if device_add fails. > > > > > > Fixes: 2c91ce8523a ("tpm: fix the rollback in tpm_chip_register()") > > > Signed-off-by: Jason Gunthorpe > > > > Pushed. > > It would make easier to merge this with resource manager commits if > there was instead > > void tpm_chip_shutdown(struct tpm_chip *chip) > { > /* Make the driver uncallable. */ > down_write(&chip->ops_sem); > if (chip->flags & TPM_CHIP_FLAG_TPM2) > tpm2_shutdown(chip, TPM2_SU_CLEAR); > chip->ops = NULL; > up_write(&chip->ops_sem); > } > > And you would call this instead of wiring into tpm_del_char_device. > > I can update the commit. > > /Jarkko Actually lets keep as it is. I'll extend tpm_del_char_device a bit instead in the RM series. /Jarkko ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot