Commit 53ade208 authored by Jia Jie Ho's avatar Jia Jie Ho Committed by Wen Zhiwei
Browse files

crypto: starfive - Fix nent assignment in rsa dec

stable inclusion
from stable-v6.6.51
commit 37b65ea6c7adcb98449e47d27c55b388c0d3b705
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAYRVR

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=37b65ea6c7adcb98449e47d27c55b388c0d3b705



--------------------------------

[ Upstream commit 8323c036789b8b4a61925fce439a89dba17b7f2f ]

Missing src scatterlist nent assignment in rsa decrypt function.
Removing all unneeded assignment and use nents value from req->src
instead.

Signed-off-by: default avatarJia Jie Ho <jiajie.ho@starfivetech.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 597f1093
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -213,7 +213,6 @@ struct starfive_cryp_request_ctx {
	struct scatterlist			*out_sg;
	struct ahash_request			ahash_fbk_req;
	size_t					total;
	size_t					nents;
	unsigned int				blksize;
	unsigned int				digsize;
	unsigned long				in_sg_len;
+1 −2
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ static int starfive_rsa_enc_core(struct starfive_cryp_ctx *ctx, int enc)
		memset(rctx->rsa_data, 0, shift);
	}

	rctx->total = sg_copy_to_buffer(rctx->in_sg, rctx->nents,
	rctx->total = sg_copy_to_buffer(rctx->in_sg, sg_nents(rctx->in_sg),
					rctx->rsa_data + shift, rctx->total);

	if (enc) {
@@ -332,7 +332,6 @@ static int starfive_rsa_enc(struct akcipher_request *req)
	rctx->in_sg = req->src;
	rctx->out_sg = req->dst;
	rctx->total = req->src_len;
	rctx->nents = sg_nents(rctx->in_sg);
	ctx->rctx = rctx;

	return starfive_rsa_enc_core(ctx, 1);