Skip to content

Commit

Permalink
crypto: starfive - Fix nent assignment in rsa dec
Browse files Browse the repository at this point in the history
[ Upstream commit 8323c03 ]

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

Signed-off-by: Jia Jie Ho <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
jiajieho authored and gregkh committed Sep 12, 2024
1 parent 0e3da92 commit 17c1e62
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion drivers/crypto/starfive/jh7110-cryp.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,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;
Expand Down
3 changes: 1 addition & 2 deletions drivers/crypto/starfive/jh7110-rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,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) {
Expand Down Expand Up @@ -309,7 +309,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);
Expand Down

0 comments on commit 17c1e62

Please sign in to comment.