RE: [PATCH] crypto: aspeed: add error handling if dmam_alloc_coherent() failed

From
Neal Liu <neal_liu@aspeedtech.com>
Date
2023-02-23 10:03:25
Also in
linux-aspeed, linux-crypto, lkml
Reply to
Herbert Xu, 2023-02-23
On Thu, Feb 23, 2023 at 04:58:30PM +0800, Neal Liu wrote:
quoted
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 <neal_liu@aspeedtech.com>
---
 drivers/crypto/aspeed/aspeed-acry.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/crypto/aspeed/aspeed-acry.c
b/drivers/crypto/aspeed/aspeed-acry.c
index 1f77ebd73489..85733e418c9e 100644
--- a/drivers/crypto/aspeed/aspeed-acry.c
+++ b/drivers/crypto/aspeed/aspeed-acry.c
@@ -782,6 +782,11 @@ static int aspeed_acry_probe(struct
platform_device *pdev)
quoted
 	acry_dev->buf_addr = dmam_alloc_coherent(dev,
ASPEED_ACRY_BUFF_SIZE,
quoted
 						 &acry_dev->buf_dma_addr,
 						 GFP_KERNEL);
+	if (!acry_dev->buf_addr) {
+		rc = -ENOMEM;
+		goto err_engine_rsa_start;
+	}
+
 	memzero_explicit(acry_dev->buf_addr, ASPEED_ACRY_BUFF_SIZE);
Please remove this memzero in a follow-up patch as dmam_alloc_coherent
returns memory that's already zeroed.

Thanks,
Okay, thanks for the information.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (3 messages) 3 messages, 2 authors, last reply 2023-02-23
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help