Skip to content

Commit

Permalink
crypto: img-hash - Fix variable dereferenced before check 'hdev->req'
Browse files Browse the repository at this point in the history
[ Upstream commit 04ba54e ]

Smatch report warning as follows:

drivers/crypto/img-hash.c:366 img_hash_dma_task() warn: variable
dereferenced before check 'hdev->req'

Variable dereferenced should be done after check 'hdev->req',
fix it.

Fixes: d358f1a ("crypto: img-hash - Add Imagination Technologies hw hash accelerator")
Fixes: 10badea ("crypto: img-hash - Fix null pointer exception")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
gscui authored and gregkh committed Dec 31, 2022
1 parent f2f2c61 commit 84ebdb6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/crypto/img-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,16 @@ static int img_hash_dma_init(struct img_hash_dev *hdev)
static void img_hash_dma_task(unsigned long d)
{
struct img_hash_dev *hdev = (struct img_hash_dev *)d;
struct img_hash_request_ctx *ctx = ahash_request_ctx(hdev->req);
struct img_hash_request_ctx *ctx;
u8 *addr;
size_t nbytes, bleft, wsend, len, tbc;
struct scatterlist tsg;

if (!hdev->req || !ctx->sg)
if (!hdev->req)
return;

ctx = ahash_request_ctx(hdev->req);
if (!ctx->sg)
return;

addr = sg_virt(ctx->sg);
Expand Down

0 comments on commit 84ebdb6

Please sign in to comment.