]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: tegra - check return value for hash do_one_req
authorAkhil R <akhilrajeev@nvidia.com>
Mon, 24 Feb 2025 09:16:04 +0000 (14:46 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 8 Mar 2025 08:22:23 +0000 (16:22 +0800)
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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202412071747.flPux4oB-lkp@intel.com/
Fixes: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver")
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/tegra/tegra-se-aes.c
drivers/crypto/tegra/tegra-se-hash.c

index c7bb6f951a846a72686c34e00ab126b09c1a904f..5ca7996ecc6da283bc5fe97ea3b75d53c4acda5b 100644 (file)
@@ -1602,18 +1602,24 @@ static int tegra_cmac_do_one_req(struct crypto_engine *engine, void *areq)
        struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
        struct tegra_cmac_ctx *ctx = crypto_ahash_ctx(tfm);
        struct tegra_se *se = ctx->se;
-       int ret;
+       int ret = 0;
 
        if (rctx->task & SHA_UPDATE) {
                ret = tegra_cmac_do_update(req);
+               if (ret)
+                       goto out;
+
                rctx->task &= ~SHA_UPDATE;
        }
 
        if (rctx->task & SHA_FINAL) {
                ret = tegra_cmac_do_final(req);
+               if (ret)
+                       goto out;
+
                rctx->task &= ~SHA_FINAL;
        }
-
+out:
        crypto_finalize_hash_request(se->engine, req, ret);
 
        return 0;
index b4a179a8febd5d13352dab59173a794822281e93..0ae5ce67bdd047164f1dfce644899340c9224ff3 100644 (file)
@@ -437,14 +437,21 @@ static int tegra_sha_do_one_req(struct crypto_engine *engine, void *areq)
 
        if (rctx->task & SHA_UPDATE) {
                ret = tegra_sha_do_update(req);
+               if (ret)
+                       goto out;
+
                rctx->task &= ~SHA_UPDATE;
        }
 
        if (rctx->task & SHA_FINAL) {
                ret = tegra_sha_do_final(req);
+               if (ret)
+                       goto out;
+
                rctx->task &= ~SHA_FINAL;
        }
 
+out:
        crypto_finalize_hash_request(se->engine, req, ret);
 
        return 0;