From: Neal Liu Date: Fri, 24 Feb 2023 02:05:21 +0000 (+0800) Subject: crypto: aspeed - add error handling if dmam_alloc_coherent() failed X-Git-Tag: v6.4-rc1~3^2~103 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=a1862c3b0875a0cdfa0e30c508855324577e124b;p=linux-block.git crypto: aspeed - add error handling if dmam_alloc_coherent() failed Since the acry_dev->buf_addr may be NULL, add error handling to prevent any additional access to avoid potential issues. Signed-off-by: Neal Liu Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/aspeed/aspeed-acry.c b/drivers/crypto/aspeed/aspeed-acry.c index 857a7a222922..565059c1ddbf 100644 --- a/drivers/crypto/aspeed/aspeed-acry.c +++ b/drivers/crypto/aspeed/aspeed-acry.c @@ -779,7 +779,10 @@ static int aspeed_acry_probe(struct platform_device *pdev) acry_dev->buf_addr = dmam_alloc_coherent(dev, ASPEED_ACRY_BUFF_SIZE, &acry_dev->buf_dma_addr, GFP_KERNEL); - memzero_explicit(acry_dev->buf_addr, ASPEED_ACRY_BUFF_SIZE); + if (!acry_dev->buf_addr) { + rc = -ENOMEM; + goto err_engine_rsa_start; + } aspeed_acry_register(acry_dev);