Skip to content

Commit 04ba54e

Browse files
gscuiherbertx
authored andcommitted
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: 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>
1 parent a428636 commit 04ba54e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/crypto/img-hash.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,16 @@ static int img_hash_dma_init(struct img_hash_dev *hdev)
358358
static void img_hash_dma_task(unsigned long d)
359359
{
360360
struct img_hash_dev *hdev = (struct img_hash_dev *)d;
361-
struct img_hash_request_ctx *ctx = ahash_request_ctx(hdev->req);
361+
struct img_hash_request_ctx *ctx;
362362
u8 *addr;
363363
size_t nbytes, bleft, wsend, len, tbc;
364364
struct scatterlist tsg;
365365

366-
if (!hdev->req || !ctx->sg)
366+
if (!hdev->req)
367+
return;
368+
369+
ctx = ahash_request_ctx(hdev->req);
370+
if (!ctx->sg)
367371
return;
368372

369373
addr = sg_virt(ctx->sg);

0 commit comments

Comments
 (0)