Commit 04ba54e5 authored by Gaosheng Cui's avatar Gaosheng Cui Committed by Herbert Xu

crypto: img-hash - Fix variable dereferenced before check 'hdev->req'

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: d358f1ab ("crypto: img-hash - Add Imagination Technologies hw hash accelerator")
Fixes: 10badea2 ("crypto: img-hash - Fix null pointer exception")
Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a428636d
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment