linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: amlogic - Add check for devm_kcalloc
@ 2022-11-22  6:22 Jiasheng Jiang
  2022-11-22  7:42 ` Neil Armstrong
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-11-22  6:22 UTC (permalink / raw)
  To: clabbe, herbert, davem
  Cc: linux-crypto, linux-amlogic, linux-kernel, Jiasheng Jiang

As the devm_kcalloc may return NULL pointer,
it should be better to add check for the return
value, as same as the others.

Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/crypto/amlogic/amlogic-gxl-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c
index 6e7ae896717c..b243d6382664 100644
--- a/drivers/crypto/amlogic/amlogic-gxl-core.c
+++ b/drivers/crypto/amlogic/amlogic-gxl-core.c
@@ -238,6 +238,9 @@ static int meson_crypto_probe(struct platform_device *pdev)
 	}
 
 	mc->irqs = devm_kcalloc(mc->dev, MAXFLOW, sizeof(int), GFP_KERNEL);
+	if (!mc->irqs)
+		return -ENOMEM;
+
 	for (i = 0; i < MAXFLOW; i++) {
 		mc->irqs[i] = platform_get_irq(pdev, i);
 		if (mc->irqs[i] < 0)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: amlogic - Add check for devm_kcalloc
  2022-11-22  6:22 [PATCH] crypto: amlogic - Add check for devm_kcalloc Jiasheng Jiang
@ 2022-11-22  7:42 ` Neil Armstrong
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Armstrong @ 2022-11-22  7:42 UTC (permalink / raw)
  To: Jiasheng Jiang, clabbe, herbert, davem
  Cc: linux-crypto, linux-amlogic, linux-kernel

On 22/11/2022 07:22, Jiasheng Jiang wrote:
> As the devm_kcalloc may return NULL pointer,
> it should be better to add check for the return
> value, as same as the others.
> 
> Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/crypto/amlogic/amlogic-gxl-core.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c
> index 6e7ae896717c..b243d6382664 100644
> --- a/drivers/crypto/amlogic/amlogic-gxl-core.c
> +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c
> @@ -238,6 +238,9 @@ static int meson_crypto_probe(struct platform_device *pdev)
>   	}
>   
>   	mc->irqs = devm_kcalloc(mc->dev, MAXFLOW, sizeof(int), GFP_KERNEL);
> +	if (!mc->irqs)
> +		return -ENOMEM;
> +
>   	for (i = 0; i < MAXFLOW; i++) {
>   		mc->irqs[i] = platform_get_irq(pdev, i);
>   		if (mc->irqs[i] < 0)


Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-22  7:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22  6:22 [PATCH] crypto: amlogic - Add check for devm_kcalloc Jiasheng Jiang
2022-11-22  7:42 ` Neil Armstrong

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).