Skip to content

Commit 1a168d8

Browse files
committed
crypto: tegra - do not transfer req when tegra init fails
jira LE-4159 Rebuild_History Non-Buildable kernel-5.14.0-570.41.1.el9_6 commit-author Chen Ridong <chenridong@huawei.com> commit 15589bd The tegra_cmac_init or tegra_sha_init function may return an error when memory is exhausted. It should not transfer the request when they return an error. Fixes: 0880bb3 ("crypto: tegra - Add Tegra Security Engine driver") Signed-off-by: Chen Ridong <chenridong@huawei.com> Acked-by: Akhil R <akhilrajeev@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 15589bd) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent d7b9b66 commit 1a168d8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

drivers/crypto/tegra/tegra-se-aes.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,10 +1752,13 @@ static int tegra_cmac_digest(struct ahash_request *req)
17521752
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
17531753
struct tegra_cmac_ctx *ctx = crypto_ahash_ctx(tfm);
17541754
struct tegra_cmac_reqctx *rctx = ahash_request_ctx(req);
1755+
int ret;
17551756

1756-
tegra_cmac_init(req);
1757-
rctx->task |= SHA_UPDATE | SHA_FINAL;
1757+
ret = tegra_cmac_init(req);
1758+
if (ret)
1759+
return ret;
17581760

1761+
rctx->task |= SHA_UPDATE | SHA_FINAL;
17591762
return crypto_transfer_hash_request_to_engine(ctx->se->engine, req);
17601763
}
17611764

drivers/crypto/tegra/tegra-se-hash.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,16 @@ static int tegra_sha_digest(struct ahash_request *req)
615615
struct tegra_sha_reqctx *rctx = ahash_request_ctx(req);
616616
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
617617
struct tegra_sha_ctx *ctx = crypto_ahash_ctx(tfm);
618+
int ret;
618619

619620
if (ctx->fallback)
620621
return tegra_sha_fallback_digest(req);
621622

622-
tegra_sha_init(req);
623-
rctx->task |= SHA_UPDATE | SHA_FINAL;
623+
ret = tegra_sha_init(req);
624+
if (ret)
625+
return ret;
624626

627+
rctx->task |= SHA_UPDATE | SHA_FINAL;
625628
return crypto_transfer_hash_request_to_engine(ctx->se->engine, req);
626629
}
627630

0 commit comments

Comments
 (0)