linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	peterhuewe@gmx.de, stefanb@linux.vnet.ibm.com,
	James.Bottomley@hansenpartnership.com,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lino Sanfilippo <l.sanfilippo@kunbus.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip
Date: Tue, 16 Feb 2021 18:11:02 +0200	[thread overview]
Message-ID: <YCvulinbuHWunTqD@kernel.org> (raw)
In-Reply-To: <YCvuS9cIT7umOjhy@kernel.org>

On Tue, Feb 16, 2021 at 06:09:50PM +0200, Jarkko Sakkinen wrote:
> On Tue, Feb 16, 2021 at 06:04:42PM +0200, Jarkko Sakkinen wrote:
> > On Tue, Feb 16, 2021 at 08:53:42AM -0400, Jason Gunthorpe wrote:
> > > On Tue, Feb 16, 2021 at 01:31:00AM +0100, Lino Sanfilippo wrote:
> > > >  
> > > > +static int tpm_add_tpm2_char_device(struct tpm_chip *chip)
> > 
> > BTW, this naming is crap.
> > 
> > - 2x tpm
> > - char is useless
> > 
> > -> tpm2_add_device
> 
> Actually, tpm2s_add_device() add put it to tpm2-space.c.

No, tpms_add_device() :-)

(sorry)

/Jarkko

> 
> > > > +{
> > > > +	int rc;
> > > > +
> > > > +	device_initialize(&chip->devs);
> > > > +	chip->devs.parent = chip->dev.parent;
> > > > +	chip->devs.class = tpmrm_class;
> > > > +
> > > > +	rc = dev_set_name(&chip->devs, "tpmrm%d", chip->dev_num);
> > > > +	if (rc)
> > > > +		goto out_put_devs;
> > 
> > Right, and empty line missing here.
> > 
> > > > +	/*
> > > > +	 * 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.
> > > > +	 */
> > > > +	get_device(&chip->dev);
> > > > +	chip->devs.release = tpm_devs_release;
> > > > +	chip->devs.devt =
> > > > +		MKDEV(MAJOR(tpm_devt), chip->dev_num + TPM_NUM_DEVICES);
> > 
> > Isn't this less than 100 chars?
> > 
> > > > +	cdev_init(&chip->cdevs, &tpmrm_fops);
> > > > +	chip->cdevs.owner = THIS_MODULE;
> > > > +
> > > > +	rc = cdev_device_add(&chip->cdevs, &chip->devs);
> > > > +	if (rc) {
> > > > +		dev_err(&chip->devs,
> > > > +			"unable to cdev_device_add() %s, major %d, minor %d, err=%d\n",
> > > > +			dev_name(&chip->devs), MAJOR(chip->devs.devt),
> > > > +			MINOR(chip->devs.devt), rc);
> > > > +		goto out_put_devs;
> > > > +	}
> > > > +
> > > > +	return 0;
> > > > +
> > > > +out_put_devs:
> > > > +	put_device(&chip->devs);
> > > 
> > > I'd rather you organize this so chip->devs.release and the get_device
> > > is always sent instead of having the possiblity for a put_device that
> > > doesn't call release
> > 
> > /Jarkko

  reply	other threads:[~2021-02-16 16:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16  0:30 [PATCH v4] TPM fixes Lino Sanfilippo
2021-02-16  0:31 ` [PATCH v4] tpm: fix reference counting for struct tpm_chip Lino Sanfilippo
2021-02-16  8:27   ` Jarkko Sakkinen
2021-02-16 12:53   ` Jason Gunthorpe
2021-02-16 16:04     ` Jarkko Sakkinen
2021-02-16 16:09       ` Jarkko Sakkinen
2021-02-16 16:11         ` Jarkko Sakkinen [this message]
2021-02-16 19:08           ` Lino Sanfilippo
2021-02-16 16:31       ` David Laight
2021-02-17 22:14         ` Jarkko Sakkinen
2021-02-18  1:27           ` Jason Gunthorpe
2021-02-19  7:07             ` Jarkko Sakkinen
2021-02-16 19:15       ` Lino Sanfilippo
2021-02-16 19:04     ` Lino Sanfilippo
2021-02-16 16:52   ` Stefan Berger
2021-02-16 19:17     ` Lino Sanfilippo

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=YCvulinbuHWunTqD@kernel.org \
    --to=jarkko@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=LinoSanfilippo@gmx.de \
    --cc=jgg@ziepe.ca \
    --cc=l.sanfilippo@kunbus.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=stable@vger.kernel.org \
    --cc=stefanb@linux.vnet.ibm.com \
    /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 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).