提交 4359669a 编写于 作者: Z Zhang Zhijie 提交者: Herbert Xu

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: NEric Biggers <ebiggers@google.com>
Fixes: 433cd2c6 ("crypto: rockchip - add crypto driver for rk3288")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: NZhang Zhijie <zhangzj@rock-chips.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 b5be8531
...@@ -119,7 +119,7 @@ static int rk_load_data(struct rk_crypto_info *dev, ...@@ -119,7 +119,7 @@ static int rk_load_data(struct rk_crypto_info *dev,
count = (dev->left_bytes > PAGE_SIZE) ? count = (dev->left_bytes > PAGE_SIZE) ?
PAGE_SIZE : dev->left_bytes; 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->addr_vir, count,
dev->total - dev->left_bytes)) { dev->total - dev->left_bytes)) {
dev_err(dev->dev, "[%s:%d] pcopy err\n", dev_err(dev->dev, "[%s:%d] pcopy err\n",
......
...@@ -207,7 +207,8 @@ struct rk_crypto_info { ...@@ -207,7 +207,8 @@ struct rk_crypto_info {
void *addr_vir; void *addr_vir;
int aligned; int aligned;
int align_size; int align_size;
size_t nents; size_t src_nents;
size_t dst_nents;
unsigned int total; unsigned int total;
unsigned int count; unsigned int count;
dma_addr_t addr_in; dma_addr_t addr_in;
......
...@@ -260,8 +260,9 @@ static int rk_ablk_start(struct rk_crypto_info *dev) ...@@ -260,8 +260,9 @@ static int rk_ablk_start(struct rk_crypto_info *dev)
dev->total = req->nbytes; dev->total = req->nbytes;
dev->sg_src = req->src; dev->sg_src = req->src;
dev->first = 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->sg_dst = req->dst;
dev->dst_nents = sg_nents(req->dst);
dev->aligned = 1; dev->aligned = 1;
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
...@@ -297,7 +298,7 @@ static int rk_ablk_rx(struct rk_crypto_info *dev) ...@@ -297,7 +298,7 @@ static int rk_ablk_rx(struct rk_crypto_info *dev)
dev->unload_data(dev); dev->unload_data(dev);
if (!dev->aligned) { 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->addr_vir, dev->count,
dev->total - dev->left_bytes - dev->total - dev->left_bytes -
dev->count)) { dev->count)) {
......
...@@ -206,7 +206,7 @@ static int rk_ahash_start(struct rk_crypto_info *dev) ...@@ -206,7 +206,7 @@ static int rk_ahash_start(struct rk_crypto_info *dev)
dev->sg_dst = NULL; dev->sg_dst = NULL;
dev->sg_src = req->src; dev->sg_src = req->src;
dev->first = 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 = ahash_request_ctx(req);
rctx->mode = 0; rctx->mode = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册