public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Zanussi <tom.zanussi@linux.intel.com>
To: Thorsten Blum <thorsten.blum@toblux.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy()
Date: Fri, 03 May 2024 15:32:52 -0500	[thread overview]
Message-ID: <7da2bc1a966061aa11110f7e0304d82dfaa322e8.camel@linux.intel.com> (raw)
In-Reply-To: <20240502153338.6945-2-thorsten.blum@toblux.com>

Hi Thorsten,

On Thu, 2024-05-02 at 17:33 +0200, Thorsten Blum wrote:
> Fixes the following two Coccinelle/coccicheck warnings reported by
> memdup.cocci:
> 
>         iaa_crypto_main.c:350:19-26: WARNING opportunity for kmemdup
>         iaa_crypto_main.c:358:18-25: WARNING opportunity for kmemdup
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
>  drivers/crypto/intel/iaa/iaa_crypto_main.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> index b2191ade9011..7635fbebe52f 100644
> --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
> +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
> @@ -347,18 +347,16 @@ int add_iaa_compression_mode(const char *name,
>                 goto free;
>  
>         if (ll_table) {
> -               mode->ll_table = kzalloc(ll_table_size, GFP_KERNEL);
> +               mode->ll_table = kmemdup(ll_table, ll_table_size, GFP_KERNEL);
>                 if (!mode->ll_table)
>                         goto free;
> -               memcpy(mode->ll_table, ll_table, ll_table_size);
>                 mode->ll_table_size = ll_table_size;
>         }
>  
>         if (d_table) {
> -               mode->d_table = kzalloc(d_table_size, GFP_KERNEL);
> +               mode->d_table = kmemdup(d_table, d_table_size, GFP_KERNEL);
>                 if (!mode->d_table)
>                         goto free;
> -               memcpy(mode->d_table, d_table, d_table_size);
>                 mode->d_table_size = d_table_size;
>         }
>  

Looks good, thanks for the cleanup.

Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>


  reply	other threads:[~2024-05-03 20:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02 15:33 [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy() Thorsten Blum
2024-05-03 20:32 ` Tom Zanussi [this message]
2024-05-10  9:23 ` Herbert Xu

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=7da2bc1a966061aa11110f7e0304d82dfaa322e8.camel@linux.intel.com \
    --to=tom.zanussi@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten.blum@toblux.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