From 112e4366ae85b6f1f1a4155a57aa37487a98f352 Mon Sep 17 00:00:00 2001 From: Sivanesan Rajapupathi Date: Tue, 16 Feb 2016 14:31:17 -0500 Subject: [PATCH] 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 Signed-off-by: Sivanesan Rajapupathi --- drivers/crypto/msm/qcrypto.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/msm/qcrypto.c b/drivers/crypto/msm/qcrypto.c index 9a6258230080..d676f5a46650 100644 --- a/drivers/crypto/msm/qcrypto.c +++ b/drivers/crypto/msm/qcrypto.c @@ -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];