Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-18 Thread Jarkko Sakkinen
On Wed, Feb 17, 2021 at 09:27:02PM -0400, Jason Gunthorpe wrote: > On Thu, Feb 18, 2021 at 12:14:11AM +0200, Jarkko Sakkinen wrote: > > On Tue, Feb 16, 2021 at 04:31:26PM +, David Laight wrote: > > > ... > > > > > > + get_device(>dev); > > > > > > + chip->devs.release = tpm_devs_release; >

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-17 Thread Jason Gunthorpe
On Thu, Feb 18, 2021 at 12:14:11AM +0200, Jarkko Sakkinen wrote: > On Tue, Feb 16, 2021 at 04:31:26PM +, David Laight wrote: > > ... > > > > > + get_device(>dev); > > > > > + chip->devs.release = tpm_devs_release; > > > > > + chip->devs.devt = > > > > > +

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-17 Thread Jarkko Sakkinen
On Tue, Feb 16, 2021 at 04:31:26PM +, David Laight wrote: > ... > > > > + get_device(>dev); > > > > + chip->devs.release = tpm_devs_release; > > > > + chip->devs.devt = > > > > + MKDEV(MAJOR(tpm_devt), chip->dev_num + TPM_NUM_DEVICES); > > > > Isn't this less

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi Stefan, On 16.02.21 at 17:52, Stefan Berger wrote: > On 2/15/21 7:31 PM, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> The following sequence of operations results in a refcount warning: >> >> 1. Open device /dev/tpmrm >> 2. Remove module tpm_tis_spi >> 3. Write a TPM command to the

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi On 16.02.21 at 17:04, Jarkko Sakkinen wrote: >>> + /* >>> +* 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(>dev);

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi, On 16.02.21 at 17:11, Jarkko Sakkinen wrote: > 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

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi, On 16.02.21 at 13:53, 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) >> +{ >> +int rc; >> + >> +device_initialize(>devs); >> +chip->devs.parent = chip->dev.parent; >> +

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Stefan Berger
On 2/15/21 7:31 PM, Lino Sanfilippo wrote: From: Lino Sanfilippo The following sequence of operations results in a refcount warning: 1. Open device /dev/tpmrm 2. Remove module tpm_tis_spi 3. Write a TPM command to the file descriptor opened at step 1. [ cut here ]

RE: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread David Laight
... > > > + get_device(>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? Still best kept under 80 if 'reasonable'? Really it is just split in the wrong

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Jarkko Sakkinen
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

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Jarkko Sakkinen
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

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Jarkko Sakkinen
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 > > +{ > > + int

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Jason Gunthorpe
On Tue, Feb 16, 2021 at 01:31:00AM +0100, Lino Sanfilippo wrote: > > +static int tpm_add_tpm2_char_device(struct tpm_chip *chip) > +{ > + int rc; > + > + device_initialize(>devs); > + chip->devs.parent = chip->dev.parent; > + chip->devs.class = tpmrm_class; > + > + rc =

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Jarkko Sakkinen
On Tue, Feb 16, 2021 at 01:31:00AM +0100, Lino Sanfilippo wrote: > From: Lino Sanfilippo > > The following sequence of operations results in a refcount warning: > > 1. Open device /dev/tpmrm Add '.' to end. > 2. Remove module tpm_tis_spi Add '.' to end. > 3. Write a TPM command to the file

[PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-15 Thread Lino Sanfilippo
From: Lino Sanfilippo The following sequence of operations results in a refcount warning: 1. Open device /dev/tpmrm 2. Remove module tpm_tis_spi 3. Write a TPM command to the file descriptor opened at step 1. [ cut here ] WARNING: CPU: 3 PID: 1161 at lib/refcount.c:25