linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Eddie James <eajames@linux.ibm.com>
Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	jgg@ziepe.ca, peterhuewe@gmx.de
Subject: Re: [PATCH v2 1/2] tpm: Use managed allocation for bios event log
Date: Thu, 26 Jan 2023 17:31:04 +0000	[thread overview]
Message-ID: <Y9K42OYk3WX7VH4E@kernel.org> (raw)
In-Reply-To: <ea8e873f-c052-832f-b4a5-0164f5cd6947@linux.ibm.com>

On Wed, Jan 25, 2023 at 01:06:31PM -0600, Eddie James wrote:
> 
> On 1/20/23 18:11, Jarkko Sakkinen wrote:
> > On Fri, Jan 13, 2023 at 10:10:16AM -0600, Eddie James wrote:
> > > Since the bios event log is freed in the device release function,
> > > let devres handle the deallocation. This will allow other memory
> > > allocation/mapping functions to be used for the bios event log.
> > > 
> > > Signed-off-by: Eddie James <eajames@linux.ibm.com>
> > > ---
> > >   drivers/char/tpm/eventlog/acpi.c |  5 +++--
> > >   drivers/char/tpm/eventlog/efi.c  | 13 +++++++------
> > >   drivers/char/tpm/eventlog/of.c   |  3 ++-
> > >   drivers/char/tpm/tpm-chip.c      |  1 -
> > >   4 files changed, 12 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/drivers/char/tpm/eventlog/acpi.c b/drivers/char/tpm/eventlog/acpi.c
> > > index 0913d3eb8d51..40360e599bc3 100644
> > > --- a/drivers/char/tpm/eventlog/acpi.c
> > > +++ b/drivers/char/tpm/eventlog/acpi.c
> > > @@ -14,6 +14,7 @@
> > >    * Access to the event log extended by the TCG BIOS of PC platform
> > >    */
> > > +#include <linux/device.h>
> > >   #include <linux/seq_file.h>
> > >   #include <linux/fs.h>
> > >   #include <linux/security.h>
> > > @@ -135,7 +136,7 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
> > >   	}
> > >   	/* malloc EventLog space */
> > > -	log->bios_event_log = kmalloc(len, GFP_KERNEL);
> > > +	log->bios_event_log = devm_kmalloc(&chip->dev, len, GFP_KERNEL);
> > >   	if (!log->bios_event_log)
> > >   		return -ENOMEM;
> > > @@ -160,7 +161,7 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
> > >   	return format;
> > >   err:
> > > -	kfree(log->bios_event_log);
> > > +	devm_kfree(&chip->dev, log->bios_event_log);
> > I wonder do we want to do devm_kfree's at all as the memory is freed during
> > detach, i.e. taken care by devres.
> 
> 
> I think we should since the chip/tpm driver will continue to probe without
> the bios event log. Therefore that memory will be wasted if there is some
> error during bios log setup.

OK, I buy this!

For this patch:

Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

If you could refine the description for the 2nd, then these would be ready
to be picked.

> Thanks,
> 
> Eddie

BR, Jarkko

  reply	other threads:[~2023-01-26 17:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 16:10 [PATCH v2 0/2] tpm: Add reserved memory event log Eddie James
2023-01-13 16:10 ` [PATCH v2 1/2] tpm: Use managed allocation for bios " Eddie James
2023-01-21  0:11   ` Jarkko Sakkinen
2023-01-25 19:06     ` Eddie James
2023-01-26 17:31       ` Jarkko Sakkinen [this message]
2023-01-13 16:10 ` [PATCH v2 2/2] tpm: Add reserved memory " Eddie James
2023-01-18 13:27   ` Stefan Berger
2023-01-18 14:49     ` Eddie James
2023-01-18 15:01       ` Stefan Berger
2023-01-21  3:58         ` Jarkko Sakkinen
2023-01-21  0:13   ` Jarkko Sakkinen

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=Y9K42OYk3WX7VH4E@kernel.org \
    --to=jarkko@kernel.org \
    --cc=eajames@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    /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).