Skip to content

Commit 3e0d61c

Browse files
Akhil Rgregkh
authored andcommitted
crypto: tegra - check return value for hash do_one_req
[ Upstream commit dcf8b7e ] Initialize and check the return value in hash *do_one_req() functions and exit the function if there is an error. This fixes the 'uninitialized variable' warnings reported by testbots. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Fixes: 0880bb3 ("crypto: tegra - Add Tegra Security Engine driver") Signed-off-by: Akhil R <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5d9147d commit 3e0d61c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,18 +1581,24 @@ static int tegra_cmac_do_one_req(struct crypto_engine *engine, void *areq)
15811581
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
15821582
struct tegra_cmac_ctx *ctx = crypto_ahash_ctx(tfm);
15831583
struct tegra_se *se = ctx->se;
1584-
int ret;
1584+
int ret = 0;
15851585

15861586
if (rctx->task & SHA_UPDATE) {
15871587
ret = tegra_cmac_do_update(req);
1588+
if (ret)
1589+
goto out;
1590+
15881591
rctx->task &= ~SHA_UPDATE;
15891592
}
15901593

15911594
if (rctx->task & SHA_FINAL) {
15921595
ret = tegra_cmac_do_final(req);
1596+
if (ret)
1597+
goto out;
1598+
15931599
rctx->task &= ~SHA_FINAL;
15941600
}
1595-
1601+
out:
15961602
crypto_finalize_hash_request(se->engine, req, ret);
15971603

15981604
return 0;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,21 @@ static int tegra_sha_do_one_req(struct crypto_engine *engine, void *areq)
417417

418418
if (rctx->task & SHA_UPDATE) {
419419
ret = tegra_sha_do_update(req);
420+
if (ret)
421+
goto out;
422+
420423
rctx->task &= ~SHA_UPDATE;
421424
}
422425

423426
if (rctx->task & SHA_FINAL) {
424427
ret = tegra_sha_do_final(req);
428+
if (ret)
429+
goto out;
430+
425431
rctx->task &= ~SHA_FINAL;
426432
}
427433

434+
out:
428435
crypto_finalize_hash_request(se->engine, req, ret);
429436

430437
return 0;

0 commit comments

Comments
 (0)