diff mbox

[1/6] crypto: img-hash - Fix null pointer exception

Message ID 1468229616-3888-2-git-send-email-will.thomas@imgtec.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show

Commit Message

Will Thomas July 11, 2016, 9:33 a.m. UTC
Sporadic null pointer exceptions came from here. Fix them.

Signed-off-by: Will Thomas <will.thomas@imgtec.com>
Reviewed-by: James Hartley <james.hartley@imgtec.com>
---
 drivers/crypto/img-hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu July 12, 2016, 7:41 a.m. UTC | #1
Will Thomas <will.thomas@imgtec.com> wrote:
> Sporadic null pointer exceptions came from here. Fix them.
> 
> Signed-off-by: Will Thomas <will.thomas@imgtec.com>
> Reviewed-by: James Hartley <james.hartley@imgtec.com>
> ---
> drivers/crypto/img-hash.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c
> index 68e8aa9..a5f270b 100644
> --- a/drivers/crypto/img-hash.c
> +++ b/drivers/crypto/img-hash.c
> @@ -361,7 +361,7 @@ static void img_hash_dma_task(unsigned long d)
>        size_t nbytes, bleft, wsend, len, tbc;
>        struct scatterlist tsg;
> 
> -       if (!ctx->sg)
> +       if (!ctx || !ctx->sg)
>                return;

This makes no sense.  ctx comes from ahash_request_ctx which can
never be NULL.  Perhaps you meant !hdev->req?

Cheers,
diff mbox

Patch

diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c
index 68e8aa9..a5f270b 100644
--- a/drivers/crypto/img-hash.c
+++ b/drivers/crypto/img-hash.c
@@ -361,7 +361,7 @@  static void img_hash_dma_task(unsigned long d)
 	size_t nbytes, bleft, wsend, len, tbc;
 	struct scatterlist tsg;
 
-	if (!ctx->sg)
+	if (!ctx || !ctx->sg)
 		return;
 
 	addr = sg_virt(ctx->sg);