crypto: msm: qcrypto: Fix hash crash if not last issue

If an ahash request is not final, the result variable of ahash_request
may not exist. In the completion callback function, then, do not
copy the digest result to result variable of ahash_request, if it not
final.  Otherwise, crash may happen.

Change-Id: I169218e8658500539b19408eca3afeabcaa4816b
Acked-by: Che-Min Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Sivanesan Rajapupathi <srajap@codeaurora.org>
This commit is contained in:
Sivanesan Rajapupathi 2016-02-16 14:31:17 -05:00 committed by David Keitel
parent 8cda113324
commit 112e4366ae

View file

@ -1,6 +1,6 @@
/* Qualcomm Crypto driver
*
* Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -1607,7 +1607,8 @@ static void _qce_ahash_complete(void *cookie, unsigned char *digest,
#endif
if (digest) {
memcpy(rctx->digest, digest, diglen);
memcpy(areq->result, digest, diglen);
if (rctx->last_blk)
memcpy(areq->result, digest, diglen);
}
if (authdata) {
rctx->byte_count[0] = auth32[0];