diff options
author | Gaosheng Cui <cuigaosheng1@huawei.com> | 2022-12-01 14:25:26 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-01-18 11:30:23 +0100 |
commit | 005f8c3d1499fcf6d708f75b592ebf2f7e626f7f (patch) | |
tree | f050dfe7d592519f4a9a3a15df41d25ab913d323 /drivers/crypto | |
parent | 164a86980b0f6edfee057fa69c0eb9075a452900 (diff) | |
download | linux-stable-005f8c3d1499fcf6d708f75b592ebf2f7e626f7f.tar.gz linux-stable-005f8c3d1499fcf6d708f75b592ebf2f7e626f7f.tar.bz2 linux-stable-005f8c3d1499fcf6d708f75b592ebf2f7e626f7f.zip |
crypto: img-hash - Fix variable dereferenced before check 'hdev->req'
[ Upstream commit 04ba54e5af8f8f0137b08cb51a0b3a2e1ea46c94 ]
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: d358f1abbf71 ("crypto: img-hash - Add Imagination Technologies hw hash accelerator")
Fixes: 10badea259fa ("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>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/img-hash.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c index b87000a0a01c..f70923643a97 100644 --- a/drivers/crypto/img-hash.c +++ b/drivers/crypto/img-hash.c @@ -359,12 +359,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); |