All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Zheng Yongjun <zhengyongjun3@huawei.com>,
	peterhuewe@gmx.de, jarkko@kernel.org,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: jgg@ziepe.ca
Subject: Re: [PATCH -next] tpm: Use kzalloc for allocating only one thing
Date: Tue, 29 Dec 2020 08:23:49 -0800	[thread overview]
Message-ID: <788cb2e68b98513c84cdc186923f7f99eb55b983.camel@HansenPartnership.com> (raw)
In-Reply-To: <20201229135154.23648-1-zhengyongjun3@huawei.com>

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?

James



  reply	other threads:[~2020-12-29 16:24 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 [this message]
2021-01-05  5:59   ` 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=788cb2e68b98513c84cdc186923f7f99eb55b983.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=jarkko@kernel.org \
    --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 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.