linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Zheng Yongjun <zhengyongjun3@huawei.com>,
	peterhuewe@gmx.de, linux-integrity@vger.kernel.org,
	linux-kernel@vger.kernel.org, jgg@ziepe.ca
Subject: Re: [PATCH -next] tpm: Use kzalloc for allocating only one thing
Date: Tue, 5 Jan 2021 07:59:05 +0200	[thread overview]
Message-ID: <20210105055905.GA24455@kernel.org> (raw)
In-Reply-To: <788cb2e68b98513c84cdc186923f7f99eb55b983.camel@HansenPartnership.com>

On Tue, Dec 29, 2020 at 08:23:49AM -0800, James Bottomley wrote:
> On Tue, 2020-12-29 at 21:51 +0800, Zheng Yongjun wrote:
> > Use kzalloc rather than kcalloc(1,...)
> > 
> > The semantic patch that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
> 
> What's the reason for wanting to do this transformation?
> 
> >  drivers/char/tpm/tpm1-cmd.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-
> > cmd.c
> > index ca7158fa6e6c..4d8415e3b778 100644
> > --- a/drivers/char/tpm/tpm1-cmd.c
> > +++ b/drivers/char/tpm/tpm1-cmd.c
> > @@ -794,7 +794,7 @@ int tpm1_pm_suspend(struct tpm_chip *chip, u32
> > tpm_suspend_pcr)
> >   */
> >  int tpm1_get_pcr_allocation(struct tpm_chip *chip)
> >  {
> > -	chip->allocated_banks = kcalloc(1, sizeof(*chip-
> > >allocated_banks),
> > +	chip->allocated_banks = kzalloc(sizeof(*chip->allocated_banks),
> >  					GFP_KERNEL);
> >  	if (!chip->allocated_banks)
> >  		return -ENOMEM;
> 
> The reason tpm1 has this is because it mirrors the allocation in tpm2
> so we retain code consistency.  It's a fairly minor advantage, so it
> could be changed if you have a better rationale ... but what is it?

Yup, I neither understand this.

> James

/Jarkko

      reply	other threads:[~2021-01-05  6:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29 13:51 [PATCH -next] tpm: Use kzalloc for allocating only one thing Zheng Yongjun
2020-12-29 16:23 ` James Bottomley
2021-01-05  5:59   ` Jarkko Sakkinen [this message]

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=20210105055905.GA24455@kernel.org \
    --to=jarkko@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=zhengyongjun3@huawei.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).