crypto: atmel-sha - fix crash when computing digest on empty message
authorCyrille Pitchen <cyrille.pitchen@atmel.com>
Fri, 15 Jan 2016 14:49:31 +0000 (15:49 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 25 Jan 2016 14:42:06 +0000 (22:42 +0800)
This patch fixes a crash which occured during the computation of the
digest of an empty message.

Indeed, when processing an empty message, the atmel_sha_handle_queue()
function was never called, hence the dd->req pointer remained
uninitialized.

Later, when the atmel_sha_final_req() function was called, it used
to crash while using this uninitialized dd->req pointer.

Hence this patch adds missing initializations of dd->req before calls of
the atmel_sha_final_req() function.

This bug prevented us from passing the tcrypt test suite on SHA algo.

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/atmel-sha.c

index 20de861aa0ea6c275edb746e14fcb372344fcd48..006b2aefba30debe4eed3a3f983f81726cea42ae 100644 (file)
@@ -939,6 +939,7 @@ static int atmel_sha_final(struct ahash_request *req)
                if (err)
                        goto err1;
 
+               dd->req = req;
                dd->flags |= SHA_FLAGS_BUSY;
                err = atmel_sha_final_req(dd);
        } else {