Skip to content

Commit

Permalink
parisc: Fix sglist access in ccio-dma.c
Browse files Browse the repository at this point in the history
commit d7da660 upstream.

This patch implements the same bug fix to ccio-dma.c as to sba_iommu.c.
It ensures that only the allocated entries of the sglist are accessed.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
danglin44 authored and gregkh committed Feb 23, 2022
1 parent 8c8e949 commit 5b6e29b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/parisc/ccio-dma.c
Expand Up @@ -1003,14 +1003,15 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
ioc->usg_calls++;
#endif

while(sg_dma_len(sglist) && nents--) {
while (nents && sg_dma_len(sglist)) {

#ifdef CCIO_COLLECT_STATS
ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT;
#endif
ccio_unmap_page(dev, sg_dma_address(sglist),
sg_dma_len(sglist), direction, 0);
++sglist;
nents--;
}

DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
Expand Down

0 comments on commit 5b6e29b

Please sign in to comment.