* [PATCH] crypto: img-hash - Fix variable dereferenced before check 'hdev->req'
@ 2022-12-01 6:25 Gaosheng Cui
2022-12-09 11:07 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Gaosheng Cui @ 2022-12-01 6:25 UTC (permalink / raw)
To: herbert, davem, james.hartley, abrestic, will.thomas, cuigaosheng1
Cc: linux-crypto
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>
---
drivers/crypto/img-hash.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c
index d8e82d69745d..9629e98bd68b 100644
--- a/drivers/crypto/img-hash.c
+++ b/drivers/crypto/img-hash.c
@@ -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);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: img-hash - Fix variable dereferenced before check 'hdev->req'
2022-12-01 6:25 [PATCH] crypto: img-hash - Fix variable dereferenced before check 'hdev->req' Gaosheng Cui
@ 2022-12-09 11:07 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2022-12-09 11:07 UTC (permalink / raw)
To: Gaosheng Cui; +Cc: davem, james.hartley, abrestic, will.thomas, linux-crypto
On Thu, Dec 01, 2022 at 02:25:26PM +0800, Gaosheng Cui wrote:
> 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>
> ---
> drivers/crypto/img-hash.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-09 11:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 6:25 [PATCH] crypto: img-hash - Fix variable dereferenced before check 'hdev->req' Gaosheng Cui
2022-12-09 11:07 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.