crypto: rockchip - fix scatterlist nents error
authorZhang Zhijie <zhangzj@rock-chips.com>
Wed, 13 Feb 2019 08:24:38 +0000 (16:24 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Feb 2019 04:47:26 +0000 (12:47 +0800)
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: 433cd2c617bf ("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>
drivers/crypto/rockchip/rk3288_crypto.c
drivers/crypto/rockchip/rk3288_crypto.h
drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
drivers/crypto/rockchip/rk3288_crypto_ahash.c

index c9d622abd90c09c5c1c87b8564502460c0456dc2..0ce4a65b95f5da82a5e14e0d843b38440512dcce 100644 (file)
@@ -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",
index d5fb4013fb42a23d520009df3e9f7a524eb2a5f3..417c445d8dea4b8bd46b92d2da9f254239614a0a 100644 (file)
@@ -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;
index 87dd571466c1a5796671e837136aa3d4f2548cce..fe2fc6c7b51b1357d9e0984c65b48d31060d3550 100644 (file)
@@ -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)) {
index 821a506b9e17f663bb2fa721ecb3e50057696c6b..c336ae75e361fa6338139fa4a14066c107ed4657 100644 (file)
@@ -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;