From: Xiang Chen <chenxiang66@xxxxxxxxxxxxx> For function dma_unmap_sg(), the <nents> parameter should be number of elements in the scatterlist prior to the mapping, not after the mapping. So fix this usage. Signed-off-by: Xiang Chen <chenxiang66@xxxxxxxxxxxxx> --- drivers/crypto/cavium/nitrox/nitrox_reqmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c index 53ef067..1263194 100644 --- a/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c +++ b/drivers/crypto/cavium/nitrox/nitrox_reqmgr.c @@ -170,7 +170,7 @@ static int dma_map_inbufs(struct nitrox_softreq *sr, sr->in.total_bytes += sg_dma_len(sg); sr->in.sg = req->src; - sr->in.sgmap_cnt = nents; + sr->in.sgmap_cnt = sg_nents(req->src); ret = create_sg_component(sr, &sr->in, sr->in.sgmap_cnt); if (ret) goto incomp_err; @@ -178,7 +178,7 @@ static int dma_map_inbufs(struct nitrox_softreq *sr, return 0; incomp_err: - dma_unmap_sg(dev, req->src, nents, DMA_BIDIRECTIONAL); + dma_unmap_sg(dev, req->src, sg_nents(req->src), DMA_BIDIRECTIONAL); sr->in.sgmap_cnt = 0; return ret; } @@ -195,7 +195,7 @@ static int dma_map_outbufs(struct nitrox_softreq *sr, return -EINVAL; sr->out.sg = req->dst; - sr->out.sgmap_cnt = nents; + sr->out.sgmap_cnt = sg_nents(req->dst); ret = create_sg_component(sr, &sr->out, sr->out.sgmap_cnt); if (ret) goto outcomp_map_err; @@ -203,7 +203,7 @@ static int dma_map_outbufs(struct nitrox_softreq *sr, return 0; outcomp_map_err: - dma_unmap_sg(dev, req->dst, nents, DMA_BIDIRECTIONAL); + dma_unmap_sg(dev, req->dst, sg_nents(req->dst), DMA_BIDIRECTIONAL); sr->out.sgmap_cnt = 0; sr->out.sg = NULL; return ret; -- 2.8.1