]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
parisc: Fix sglist access in ccio-dma.c
authorJohn David Anglin <dave.anglin@bell.net>
Thu, 27 Jan 2022 22:33:41 +0000 (22:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 10:58:37 +0000 (11:58 +0100)
commit d7da660cab47183cded65e11b64497d0f56c6edf 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>
drivers/parisc/ccio-dma.c

index b7b2e811d547192b232f27399d82b568be9ecc85..6efab7a06c5fc929b72b9f332037db4cdbefcb91 100644 (file)
@@ -1010,7 +1010,7 @@ 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;
@@ -1018,6 +1018,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
                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);