Skip to content

Commit

Permalink
crypto: aspeed - add error handling if dmam_alloc_coherent() failed
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Neal Liu authored and Herbert Xu committed Mar 14, 2023
1 parent f84155c commit a1862c3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/crypto/aspeed/aspeed-acry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a1862c3

Please sign in to comment.