* [PATCH] crypto: axis/artpec6: change from kzalloc to kcalloc in artpec6_crypto_probe()
@ 2025-03-09 0:30 Ethan Carter Edwards
2025-03-10 7:07 ` Jesper Nilsson
2025-03-15 9:17 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Ethan Carter Edwards @ 2025-03-09 0:30 UTC (permalink / raw)
To: Jesper Nilsson, Lars Persson, Herbert Xu, David S. Miller
Cc: linux-arm-kernel, linux-crypto, linux-kernel, linux-hardening,
Ethan Carter Edwards
We are trying to get rid of all multiplications from allocation
functions to prevent potential integer overflows. Here the
multiplication is probably safe, but using kcalloc() is more
appropriate and improves readability. This patch has no effect
on runtime behavior.
Link: https://github.com/KSPP/linux/issues/162 [1]
Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
drivers/crypto/axis/artpec6_crypto.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
index 1c1f57baef0ea9f4ecf7ab39f2c0e9e4327ef568..500b08e42282608348481b759e0b79d25f0b5db0 100644
--- a/drivers/crypto/axis/artpec6_crypto.c
+++ b/drivers/crypto/axis/artpec6_crypto.c
@@ -2897,13 +2897,13 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
tasklet_init(&ac->task, artpec6_crypto_task,
(unsigned long)ac);
- ac->pad_buffer = devm_kzalloc(&pdev->dev, 2 * ARTPEC_CACHE_LINE_MAX,
+ ac->pad_buffer = devm_kcalloc(&pdev->dev, 2, ARTPEC_CACHE_LINE_MAX,
GFP_KERNEL);
if (!ac->pad_buffer)
return -ENOMEM;
ac->pad_buffer = PTR_ALIGN(ac->pad_buffer, ARTPEC_CACHE_LINE_MAX);
- ac->zero_buffer = devm_kzalloc(&pdev->dev, 2 * ARTPEC_CACHE_LINE_MAX,
+ ac->zero_buffer = devm_kcalloc(&pdev->dev, 2, ARTPEC_CACHE_LINE_MAX,
GFP_KERNEL);
if (!ac->zero_buffer)
return -ENOMEM;
---
base-commit: 0a2f889128969dab41861b6e40111aa03dc57014
change-id: 20250308-artpec6-devm_kcalloc-9a11cc6acb84
Best regards,
--
Ethan Carter Edwards <ethan@ethancedwards.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: axis/artpec6: change from kzalloc to kcalloc in artpec6_crypto_probe()
2025-03-09 0:30 [PATCH] crypto: axis/artpec6: change from kzalloc to kcalloc in artpec6_crypto_probe() Ethan Carter Edwards
@ 2025-03-10 7:07 ` Jesper Nilsson
2025-03-15 9:17 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Jesper Nilsson @ 2025-03-10 7:07 UTC (permalink / raw)
To: Ethan Carter Edwards
Cc: Jesper Nilsson, Lars Persson, Herbert Xu, David S. Miller,
linux-arm-kernel, linux-crypto, linux-kernel, linux-hardening
On Sat, Mar 08, 2025 at 07:30:52PM -0500, Ethan Carter Edwards wrote:
> We are trying to get rid of all multiplications from allocation
> functions to prevent potential integer overflows. Here the
> multiplication is probably safe, but using kcalloc() is more
> appropriate and improves readability. This patch has no effect
> on runtime behavior.
>
> Link: https://github.com/KSPP/linux/issues/162 [1]
> Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
>
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
> ---
> drivers/crypto/axis/artpec6_crypto.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
> index 1c1f57baef0ea9f4ecf7ab39f2c0e9e4327ef568..500b08e42282608348481b759e0b79d25f0b5db0 100644
> --- a/drivers/crypto/axis/artpec6_crypto.c
> +++ b/drivers/crypto/axis/artpec6_crypto.c
> @@ -2897,13 +2897,13 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
> tasklet_init(&ac->task, artpec6_crypto_task,
> (unsigned long)ac);
>
> - ac->pad_buffer = devm_kzalloc(&pdev->dev, 2 * ARTPEC_CACHE_LINE_MAX,
> + ac->pad_buffer = devm_kcalloc(&pdev->dev, 2, ARTPEC_CACHE_LINE_MAX,
> GFP_KERNEL);
> if (!ac->pad_buffer)
> return -ENOMEM;
> ac->pad_buffer = PTR_ALIGN(ac->pad_buffer, ARTPEC_CACHE_LINE_MAX);
>
> - ac->zero_buffer = devm_kzalloc(&pdev->dev, 2 * ARTPEC_CACHE_LINE_MAX,
> + ac->zero_buffer = devm_kcalloc(&pdev->dev, 2, ARTPEC_CACHE_LINE_MAX,
> GFP_KERNEL);
> if (!ac->zero_buffer)
> return -ENOMEM;
>
> ---
> base-commit: 0a2f889128969dab41861b6e40111aa03dc57014
> change-id: 20250308-artpec6-devm_kcalloc-9a11cc6acb84
>
> Best regards,
> --
> Ethan Carter Edwards <ethan@ethancedwards.com>
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: axis/artpec6: change from kzalloc to kcalloc in artpec6_crypto_probe()
2025-03-09 0:30 [PATCH] crypto: axis/artpec6: change from kzalloc to kcalloc in artpec6_crypto_probe() Ethan Carter Edwards
2025-03-10 7:07 ` Jesper Nilsson
@ 2025-03-15 9:17 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2025-03-15 9:17 UTC (permalink / raw)
To: Ethan Carter Edwards
Cc: Jesper Nilsson, Lars Persson, David S. Miller, linux-arm-kernel,
linux-crypto, linux-kernel, linux-hardening
On Sat, Mar 08, 2025 at 07:30:52PM -0500, Ethan Carter Edwards wrote:
> We are trying to get rid of all multiplications from allocation
> functions to prevent potential integer overflows. Here the
> multiplication is probably safe, but using kcalloc() is more
> appropriate and improves readability. This patch has no effect
> on runtime behavior.
>
> Link: https://github.com/KSPP/linux/issues/162 [1]
> Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
>
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> ---
> drivers/crypto/axis/artpec6_crypto.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 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:[~2025-03-15 9:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09 0:30 [PATCH] crypto: axis/artpec6: change from kzalloc to kcalloc in artpec6_crypto_probe() Ethan Carter Edwards
2025-03-10 7:07 ` Jesper Nilsson
2025-03-15 9:17 ` Herbert Xu
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).