From 77c91508d594c27891c2c715903bf047df6fe73a Mon Sep 17 00:00:00 2001 From: Akhil R Date: Tue, 11 Feb 2025 15:45:34 +0530 Subject: [PATCH] crypto: tegra: finalize crypto req on error Call the crypto finalize function before exiting *do_one_req() functions. This allows the driver to take up further requests even if the previous one fails. Bug 4883011 Signed-off-by: Akhil R Change-Id: I36ee3548159e96432e7d15b93f7ef688022dbc87 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3328438 Reviewed-by: Laxman Dewangan GVS: buildbot_gerritrpt --- drivers/crypto/tegra/tegra-se-aes.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c index 5846989d..6855ca8c 100644 --- a/drivers/crypto/tegra/tegra-se-aes.c +++ b/drivers/crypto/tegra/tegra-se-aes.c @@ -1510,9 +1510,10 @@ static int tegra_gcm_do_one_req(struct crypto_engine *engine, void *areq) rctx->inbuf.size = rctx->assoclen + rctx->authsize + rctx->cryptlen; rctx->inbuf.buf = dma_alloc_coherent(ctx->se->dev, rctx->inbuf.size, &rctx->inbuf.addr, GFP_KERNEL); - if (!rctx->inbuf.buf) - return -ENOMEM; - + if (!rctx->inbuf.buf) { + ret = -ENOMEM; + goto out_finalize; + } rctx->outbuf.size = rctx->assoclen + rctx->authsize + rctx->cryptlen; rctx->outbuf.buf = dma_alloc_coherent(ctx->se->dev, rctx->outbuf.size, @@ -1560,6 +1561,7 @@ outbuf_err: dma_free_coherent(ctx->se->dev, rctx->inbuf.size, rctx->inbuf.buf, rctx->inbuf.addr); +out_finalize: /* Finalize the request if there are no errors */ crypto_finalize_aead_request(ctx->se->engine, req, ret);