crypto: rockchip - fix scatterlist nents error
In some cases, the nents of src scatterlist is different from
dst scatterlist. So two variables are used to handle the nents
of src&dst scatterlist.
Reported-by: Eric Biggers <ebiggers@google.com>
Fixes: 433cd2c617
("crypto: rockchip - add crypto driver for rk3288")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: Zhang Zhijie <zhangzj@rock-chips.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
b5be853181
commit
4359669a08
@ -119,7 +119,7 @@ static int rk_load_data(struct rk_crypto_info *dev,
|
||||
count = (dev->left_bytes > PAGE_SIZE) ?
|
||||
PAGE_SIZE : dev->left_bytes;
|
||||
|
||||
if (!sg_pcopy_to_buffer(dev->first, dev->nents,
|
||||
if (!sg_pcopy_to_buffer(dev->first, dev->src_nents,
|
||||
dev->addr_vir, count,
|
||||
dev->total - dev->left_bytes)) {
|
||||
dev_err(dev->dev, "[%s:%d] pcopy err\n",
|
||||
|
@ -207,7 +207,8 @@ struct rk_crypto_info {
|
||||
void *addr_vir;
|
||||
int aligned;
|
||||
int align_size;
|
||||
size_t nents;
|
||||
size_t src_nents;
|
||||
size_t dst_nents;
|
||||
unsigned int total;
|
||||
unsigned int count;
|
||||
dma_addr_t addr_in;
|
||||
|
@ -260,8 +260,9 @@ static int rk_ablk_start(struct rk_crypto_info *dev)
|
||||
dev->total = req->nbytes;
|
||||
dev->sg_src = req->src;
|
||||
dev->first = req->src;
|
||||
dev->nents = sg_nents(req->src);
|
||||
dev->src_nents = sg_nents(req->src);
|
||||
dev->sg_dst = req->dst;
|
||||
dev->dst_nents = sg_nents(req->dst);
|
||||
dev->aligned = 1;
|
||||
|
||||
spin_lock_irqsave(&dev->lock, flags);
|
||||
@ -297,7 +298,7 @@ static int rk_ablk_rx(struct rk_crypto_info *dev)
|
||||
|
||||
dev->unload_data(dev);
|
||||
if (!dev->aligned) {
|
||||
if (!sg_pcopy_from_buffer(req->dst, dev->nents,
|
||||
if (!sg_pcopy_from_buffer(req->dst, dev->dst_nents,
|
||||
dev->addr_vir, dev->count,
|
||||
dev->total - dev->left_bytes -
|
||||
dev->count)) {
|
||||
|
@ -206,7 +206,7 @@ static int rk_ahash_start(struct rk_crypto_info *dev)
|
||||
dev->sg_dst = NULL;
|
||||
dev->sg_src = req->src;
|
||||
dev->first = req->src;
|
||||
dev->nents = sg_nents(req->src);
|
||||
dev->src_nents = sg_nents(req->src);
|
||||
rctx = ahash_request_ctx(req);
|
||||
rctx->mode = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user