Message ID | 20241111012827.1788341-1-chenridong@huaweicloud.com |
---|---|
State | New |
Headers | show |
Series | [v2] crypto: tegra - do not transfer req when tegra init fails | expand |
On 2024/11/11 9:28, Chen Ridong wrote: > From: Chen Ridong <chenridong@huawei.com> > > 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: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver") > Signed-off-by: Chen Ridong <chenridong@huawei.com> > Acked-by: Akhil R <akhilrajeev@nvidia.com> > --- > drivers/crypto/tegra/tegra-se-aes.c | 7 +++++-- > drivers/crypto/tegra/tegra-se-hash.c | 7 +++++-- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c > index 9d130592cc0a..d734c9a56786 100644 > --- a/drivers/crypto/tegra/tegra-se-aes.c > +++ b/drivers/crypto/tegra/tegra-se-aes.c > @@ -1750,10 +1750,13 @@ static int tegra_cmac_digest(struct ahash_request *req) > 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); > + int ret; > > - 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); > } > > diff --git a/drivers/crypto/tegra/tegra-se-hash.c b/drivers/crypto/tegra/tegra-se-hash.c > index 4d4bd727f498..0b5cdd5676b1 100644 > --- a/drivers/crypto/tegra/tegra-se-hash.c > +++ b/drivers/crypto/tegra/tegra-se-hash.c > @@ -615,13 +615,16 @@ static int tegra_sha_digest(struct ahash_request *req) > struct tegra_sha_reqctx *rctx = ahash_request_ctx(req); > struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); > struct tegra_sha_ctx *ctx = crypto_ahash_ctx(tfm); > + int ret; > > if (ctx->fallback) > return tegra_sha_fallback_digest(req); > > - tegra_sha_init(req); > - rctx->task |= SHA_UPDATE | SHA_FINAL; > + ret = tegra_sha_init(req); > + if (ret) > + return ret; > > + rctx->task |= SHA_UPDATE | SHA_FINAL; > return crypto_transfer_hash_request_to_engine(ctx->se->engine, req); > } > Friendly ping.
On Mon, Nov 11, 2024 at 01:28:27AM +0000, Chen Ridong wrote: > From: Chen Ridong <chenridong@huawei.com> > > 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: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver") > Signed-off-by: Chen Ridong <chenridong@huawei.com> > Acked-by: Akhil R <akhilrajeev@nvidia.com> > --- > drivers/crypto/tegra/tegra-se-aes.c | 7 +++++-- > drivers/crypto/tegra/tegra-se-hash.c | 7 +++++-- > 2 files changed, 10 insertions(+), 4 deletions(-) Acked-by: Thierry Reding <treding@nvidia.com>
On Mon, Nov 11, 2024 at 01:28:27AM +0000, Chen Ridong wrote: > From: Chen Ridong <chenridong@huawei.com> > > 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: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver") > Signed-off-by: Chen Ridong <chenridong@huawei.com> > Acked-by: Akhil R <akhilrajeev@nvidia.com> > --- > drivers/crypto/tegra/tegra-se-aes.c | 7 +++++-- > drivers/crypto/tegra/tegra-se-hash.c | 7 +++++-- > 2 files changed, 10 insertions(+), 4 deletions(-) Patch applied. Thanks.
diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c index 9d130592cc0a..d734c9a56786 100644 --- a/drivers/crypto/tegra/tegra-se-aes.c +++ b/drivers/crypto/tegra/tegra-se-aes.c @@ -1750,10 +1750,13 @@ static int tegra_cmac_digest(struct ahash_request *req) 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); + int ret; - 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); } diff --git a/drivers/crypto/tegra/tegra-se-hash.c b/drivers/crypto/tegra/tegra-se-hash.c index 4d4bd727f498..0b5cdd5676b1 100644 --- a/drivers/crypto/tegra/tegra-se-hash.c +++ b/drivers/crypto/tegra/tegra-se-hash.c @@ -615,13 +615,16 @@ static int tegra_sha_digest(struct ahash_request *req) struct tegra_sha_reqctx *rctx = ahash_request_ctx(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct tegra_sha_ctx *ctx = crypto_ahash_ctx(tfm); + int ret; if (ctx->fallback) return tegra_sha_fallback_digest(req); - tegra_sha_init(req); - rctx->task |= SHA_UPDATE | SHA_FINAL; + ret = tegra_sha_init(req); + if (ret) + return ret; + rctx->task |= SHA_UPDATE | SHA_FINAL; return crypto_transfer_hash_request_to_engine(ctx->se->engine, req); }