* [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups
@ 2025-05-03 20:21 Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 1/2] crypto: hisilicon/qm - remove sizeof(char) Ethan Carter Edwards
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ethan Carter Edwards @ 2025-05-03 20:21 UTC (permalink / raw)
To: Weili Qian, Zhou Wang, Herbert Xu, David S. Miller,
Gustavo A. R. Silva
Cc: linux-crypto, linux-kernel, linux-hardening, Ethan Carter Edwards
This series contains two small cleanups to improve code quality and
readability. One removes a sizeof(char) piece of code (because it
evaluates to 1 anyways) and one switches to the helper function
devm_kcalloc.
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
Ethan Carter Edwards (2):
crypto: hisilicon/qm - remove sizeof(char)
crypto: hisilicon/qm - replace devm_kzalloc with devm_kcalloc
drivers/crypto/hisilicon/qm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
base-commit: 37ff6e9a2ce321b7932d3987701757fb4d87b0e6
change-id: 20250503-hisilicon_qm-7b581a9b3799
Best regards,
--
Ethan Carter Edwards <ethan@ethancedwards.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] crypto: hisilicon/qm - remove sizeof(char)
2025-05-03 20:21 [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Ethan Carter Edwards
@ 2025-05-03 20:21 ` Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 2/2] crypto: hisilicon/qm - replace devm_kzalloc with devm_kcalloc Ethan Carter Edwards
2025-05-05 12:28 ` [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Herbert Xu
2 siblings, 0 replies; 4+ messages in thread
From: Ethan Carter Edwards @ 2025-05-03 20:21 UTC (permalink / raw)
To: Weili Qian, Zhou Wang, Herbert Xu, David S. Miller,
Gustavo A. R. Silva
Cc: linux-crypto, linux-kernel, linux-hardening, Ethan Carter Edwards
`sizeof(char)` evaluates to 1. Remove the churn.
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
drivers/crypto/hisilicon/qm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index d3f5d108b898bb5fa6ef901070e9e97b02afb29a..80d57f0dbf26e2902e01103b0a705234009161ee 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -862,7 +862,7 @@ int hisi_qm_set_algs(struct hisi_qm *qm, u64 alg_msk, const struct qm_dev_alg *d
return -EINVAL;
}
- algs = devm_kzalloc(dev, QM_DEV_ALG_MAX_LEN * sizeof(char), GFP_KERNEL);
+ algs = devm_kzalloc(dev, QM_DEV_ALG_MAX_LEN, GFP_KERNEL);
if (!algs)
return -ENOMEM;
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] crypto: hisilicon/qm - replace devm_kzalloc with devm_kcalloc
2025-05-03 20:21 [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 1/2] crypto: hisilicon/qm - remove sizeof(char) Ethan Carter Edwards
@ 2025-05-03 20:21 ` Ethan Carter Edwards
2025-05-05 12:28 ` [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Herbert Xu
2 siblings, 0 replies; 4+ messages in thread
From: Ethan Carter Edwards @ 2025-05-03 20:21 UTC (permalink / raw)
To: Weili Qian, Zhou Wang, Herbert Xu, David S. Miller,
Gustavo A. R. Silva
Cc: linux-crypto, linux-kernel, linux-hardening, Ethan Carter Edwards
Replace devm_kzalloc that has an internal multiplication with
devm_kcalloc to improve code readability and safety from overflows.
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
drivers/crypto/hisilicon/qm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 80d57f0dbf26e2902e01103b0a705234009161ee..7c41f9593d039157ad900ee9fcc00e137d2ec169 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -5224,7 +5224,7 @@ static int qm_pre_store_caps(struct hisi_qm *qm)
size_t i, size;
size = ARRAY_SIZE(qm_cap_query_info);
- qm_cap = devm_kzalloc(&pdev->dev, sizeof(*qm_cap) * size, GFP_KERNEL);
+ qm_cap = devm_kcalloc(&pdev->dev, sizeof(*qm_cap), size, GFP_KERNEL);
if (!qm_cap)
return -ENOMEM;
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups
2025-05-03 20:21 [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 1/2] crypto: hisilicon/qm - remove sizeof(char) Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 2/2] crypto: hisilicon/qm - replace devm_kzalloc with devm_kcalloc Ethan Carter Edwards
@ 2025-05-05 12:28 ` Herbert Xu
2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2025-05-05 12:28 UTC (permalink / raw)
To: Ethan Carter Edwards
Cc: Weili Qian, Zhou Wang, David S. Miller, Gustavo A. R. Silva,
linux-crypto, linux-kernel, linux-hardening
On Sat, May 03, 2025 at 04:21:26PM -0400, Ethan Carter Edwards wrote:
> This series contains two small cleanups to improve code quality and
> readability. One removes a sizeof(char) piece of code (because it
> evaluates to 1 anyways) and one switches to the helper function
> devm_kcalloc.
>
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> ---
> Ethan Carter Edwards (2):
> crypto: hisilicon/qm - remove sizeof(char)
> crypto: hisilicon/qm - replace devm_kzalloc with devm_kcalloc
>
> drivers/crypto/hisilicon/qm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> ---
> base-commit: 37ff6e9a2ce321b7932d3987701757fb4d87b0e6
> change-id: 20250503-hisilicon_qm-7b581a9b3799
All 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] 4+ messages in thread
end of thread, other threads:[~2025-05-05 12:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-03 20:21 [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 1/2] crypto: hisilicon/qm - remove sizeof(char) Ethan Carter Edwards
2025-05-03 20:21 ` [PATCH 2/2] crypto: hisilicon/qm - replace devm_kzalloc with devm_kcalloc Ethan Carter Edwards
2025-05-05 12:28 ` [PATCH 0/2] crypto: hisilicon/qm - memory allocation cleanups Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox