* [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy()
@ 2024-05-02 15:33 Thorsten Blum
2024-05-03 20:32 ` Tom Zanussi
2024-05-10 9:23 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2024-05-02 15:33 UTC (permalink / raw)
To: Tom Zanussi, Herbert Xu, David S. Miller
Cc: linux-crypto, linux-kernel, Thorsten Blum
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;
}
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy()
2024-05-02 15:33 [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy() Thorsten Blum
@ 2024-05-03 20:32 ` Tom Zanussi
2024-05-10 9:23 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Tom Zanussi @ 2024-05-03 20:32 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller; +Cc: linux-crypto, linux-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy()
2024-05-02 15:33 [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy() Thorsten Blum
2024-05-03 20:32 ` Tom Zanussi
@ 2024-05-10 9:23 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2024-05-10 9:23 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Tom Zanussi, David S. Miller, linux-crypto, linux-kernel
On Thu, May 02, 2024 at 05:33:39PM +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(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-10 9:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-02 15:33 [PATCH] crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy() Thorsten Blum
2024-05-03 20:32 ` Tom Zanussi
2024-05-10 9:23 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox