diff mbox series

crypto: tegra - do not transfer req when tegra_cmac_init returns an error

Message ID 20241107012407.1669481-1-chenridong@huaweicloud.com (mailing list archive)
State Under Review
Delegated to: Herbert Xu
Headers show
Series crypto: tegra - do not transfer req when tegra_cmac_init returns an error | expand

Commit Message

Chen Ridong Nov. 7, 2024, 1:24 a.m. UTC
From: Chen Ridong <chenridong@huawei.com>

The tegra_cmac_init function may return an error when memory is exhausted.
It should not transfer the request when tegra_cmac_init returns an error.

Fixes: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 drivers/crypto/tegra/tegra-se-aes.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c
index 9d130592cc0a..10cd19427530 100644
--- a/drivers/crypto/tegra/tegra-se-aes.c
+++ b/drivers/crypto/tegra/tegra-se-aes.c
@@ -1747,13 +1747,16 @@  static int tegra_cmac_finup(struct ahash_request *req)
 
 static int tegra_cmac_digest(struct ahash_request *req)
 {
+	int ret;
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
 	struct tegra_cmac_ctx *ctx = crypto_ahash_ctx(tfm);
 	struct tegra_cmac_reqctx *rctx = ahash_request_ctx(req);
 
-	tegra_cmac_init(req);
-	rctx->task |= SHA_UPDATE | SHA_FINAL;
+	ret = tegra_cmac_init(req);
+	if (ret)
+		return ret;
 
+	rctx->task |= SHA_UPDATE | SHA_FINAL;
 	return crypto_transfer_hash_request_to_engine(ctx->se->engine, req);
 }