From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Jarkko Sakkinen
<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Peter Huewe <peterhuewe-Mmb7MZpHnFY@public.gmane.org>,
Ashley Lai <ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org>,
Marcel Selhorst <tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [tpmdd-devel] [PATCH v2 2/7] tpm: two-phase chip management functions
Date: Tue, 7 Oct 2014 16:34:42 -0600 [thread overview]
Message-ID: <20141007223442.GA3014@obsidianresearch.com> (raw)
In-Reply-To: <20141007222814.GA7262-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On Wed, Oct 08, 2014 at 01:28:14AM +0300, Jarkko Sakkinen wrote:
> > > @@ -714,15 +709,10 @@ static int tpm_tis_i2c_remove(struct i2c_client *client)
> > > struct tpm_chip *chip = tpm_dev.chip;
> > > release_locality(chip, chip->vendor.locality, 1);
> > >
> > > - /* close file handles */
> > > - tpm_dev_vendor_release(chip);
> > > -
> > > /* remove hardware */
> > > tpm_remove_hardware(chip->dev);
> >
> > Wrong ordering here, tpm_remove_hardware should always be first -
> > drivers should not tear down internal state before calling it, so
> > release_locality should be second.
> >
> > Noting that since we use devm the kfree will not happen until
> > remove returns, so the chip pointer is still valid.
>
> Should I fix this ordering? I was thinking to focus putting proper
> patterns in place only in tpm_tis and tpm_crb because they are the
> that I'm able to test easily and then they can work as guideline for
> other drivers.
I think since this patch is already touching this function there is
no reason not to make it be correct (especially since it was noticed)
The rest can wait till we globally replace tpm_remove_hardware with
tpm_unregister - at that time the ordering can be audited and
checked.
Then the drivers will be clean and the core can finally be fixed.
Jason
WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>,
Ashley Lai <ashley@ashleylai.com>,
Marcel Selhorst <tpmdd@selhorst.net>,
linux-api@vger.kernel.org, tpmdd-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [tpmdd-devel] [PATCH v2 2/7] tpm: two-phase chip management functions
Date: Tue, 7 Oct 2014 16:34:42 -0600 [thread overview]
Message-ID: <20141007223442.GA3014@obsidianresearch.com> (raw)
In-Reply-To: <20141007222814.GA7262@intel.com>
On Wed, Oct 08, 2014 at 01:28:14AM +0300, Jarkko Sakkinen wrote:
> > > @@ -714,15 +709,10 @@ static int tpm_tis_i2c_remove(struct i2c_client *client)
> > > struct tpm_chip *chip = tpm_dev.chip;
> > > release_locality(chip, chip->vendor.locality, 1);
> > >
> > > - /* close file handles */
> > > - tpm_dev_vendor_release(chip);
> > > -
> > > /* remove hardware */
> > > tpm_remove_hardware(chip->dev);
> >
> > Wrong ordering here, tpm_remove_hardware should always be first -
> > drivers should not tear down internal state before calling it, so
> > release_locality should be second.
> >
> > Noting that since we use devm the kfree will not happen until
> > remove returns, so the chip pointer is still valid.
>
> Should I fix this ordering? I was thinking to focus putting proper
> patterns in place only in tpm_tis and tpm_crb because they are the
> that I'm able to test easily and then they can work as guideline for
> other drivers.
I think since this patch is already touching this function there is
no reason not to make it be correct (especially since it was noticed)
The rest can wait till we globally replace tpm_remove_hardware with
tpm_unregister - at that time the ordering can be audited and
checked.
Then the drivers will be clean and the core can finally be fixed.
Jason
next prev parent reply other threads:[~2014-10-07 22:34 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 17:01 [PATCH v2 0/7] TPM 2.0 support Jarkko Sakkinen
2014-10-07 17:01 ` Jarkko Sakkinen
2014-10-07 17:01 ` [PATCH v2 1/7] tpm: merge duplicate transmit_cmd() functions Jarkko Sakkinen
[not found] ` <1412701277-27794-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-10-07 17:01 ` [PATCH v2 2/7] tpm: two-phase chip management functions Jarkko Sakkinen
2014-10-07 17:01 ` Jarkko Sakkinen
2014-10-07 17:50 ` [tpmdd-devel] " Jason Gunthorpe
[not found] ` <20141007175017.GA10432-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-10-07 18:04 ` Jarkko Sakkinen
2014-10-07 18:04 ` Jarkko Sakkinen
[not found] ` <20141007180417.GA29459-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-10-07 18:27 ` Jason Gunthorpe
2014-10-07 18:27 ` Jason Gunthorpe
[not found] ` <20141007182756.GA10774-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-10-07 19:15 ` Jarkko Sakkinen
2014-10-07 19:15 ` Jarkko Sakkinen
2014-10-07 22:28 ` Jarkko Sakkinen
2014-10-07 22:28 ` Jarkko Sakkinen
[not found] ` <20141007222814.GA7262-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-10-07 22:34 ` Jason Gunthorpe [this message]
2014-10-07 22:34 ` Jason Gunthorpe
[not found] ` <20141007223442.GA3014-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-10-09 9:07 ` Jarkko Sakkinen
2014-10-09 9:07 ` Jarkko Sakkinen
2014-10-07 17:01 ` [PATCH v2 7/7] tpm: TPM 2.0 FIFO Interface Jarkko Sakkinen
2014-10-07 17:01 ` Jarkko Sakkinen
2014-10-07 17:01 ` [PATCH v2 3/7] tpm: clean up tpm_tis driver life-cycle Jarkko Sakkinen
[not found] ` <1412701277-27794-4-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-10-07 17:53 ` [tpmdd-devel] " Jason Gunthorpe
2014-10-07 17:53 ` Jason Gunthorpe
2014-10-07 17:01 ` [PATCH v2 4/7] tpm: TPM 2.0 commands Jarkko Sakkinen
2014-10-07 17:01 ` [PATCH v2 5/7] tpm: TPM 2.0 sysfs attributes Jarkko Sakkinen
2014-10-07 17:01 ` [PATCH v2 6/7] tpm: TPM 2.0 CRB Interface Jarkko Sakkinen
[not found] ` <1412701277-27794-7-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-10-07 17:54 ` [tpmdd-devel] " Jason Gunthorpe
2014-10-07 17:54 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141007223442.GA3014@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org \
--cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=peterhuewe-Mmb7MZpHnFY@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.