From patchwork Thu Jan 27 22:33:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 12727484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FC94C433F5 for ; Thu, 27 Jan 2022 22:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241008AbiA0WeE (ORCPT ); Thu, 27 Jan 2022 17:34:04 -0500 Received: from mta-mtl-003.bell.net ([209.71.208.13]:26806 "EHLO cmx-mtlrgo001.bell.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239018AbiA0WeE (ORCPT ); Thu, 27 Jan 2022 17:34:04 -0500 X-RG-CM-BuS: 0 X-RG-CM-SC: 0 X-RG-CM: Clean X-Originating-IP: [70.50.7.94] X-RG-Env-Sender: dave.anglin@bell.net X-RG-Rigid: 61E9B8D000908B4A X-CM-Envelope: MS4xfIOrTKdufD3UM+ssI63W2ayr/UsO+BgK0D7duqoQLUBk7TOYXm5y47USlq2hgd/p2/9dTYU22g/dJpwFm2zCz61oKK9IHgYWSDhSY6g4CTXaT9dL4z08 pRChzGGrhxuj1Ew4EKCJgE6EwR71aHutB3fPdRBiGpAEcsvfkUKg9Wr2diyoualWLoOmFvWym2P62anfb8ceWa16Le7tuxpJKC+a706wa7sDIjCpcdyzYndx tZmnzcqCf6kiHJdZcFezNq+sm1PEhbnly2o3j2mqpwwADwD6HuruWryMvDnBBBH8PsMnBuItjlQjnZ1zhGexhbvyu495Gxt1a58ds2RXVmZTTQEgJ4QoBsQj 3RgEEO+2Tu1Fi+mhSlgRHHpdrOrL+dyi37mmcBfjKI2O9+UogwrizywpoDSw4sJGqgfI8QValP8SNZgHzpqJEbFzMXEIFwna3JdwvwCgYbHF38hb0b1qaMQv MzzbUvt7GtLCx13KswiJmVnv+DbuURiGoBjreP3Wi2j5+eWN/f2vjLC1/Cv+km8UDWIIV8R0WuajAaNruFoLmtW9ltlyYQujm5WC2wgFONuTxuSA9cUF33Ut 3oGJE6dmSqEfRd/t+Ho0FeaEH6NOE6oKYAy8xY9nPEKaDA== X-CM-Analysis: v=2.4 cv=eZxew5IH c=1 sm=1 tr=0 ts=61f31dc6 a=9k1bCY7nR7m1ZFzoCuQ56g==:117 a=9k1bCY7nR7m1ZFzoCuQ56g==:17 a=DghFqjY3_ZEA:10 a=FBHGMhGWAAAA:8 a=HblYpiq5tT6TEsmxS5EA:9 a=CjuIK1q_8ugA:10 a=_TZt9d5dLS8edx5Vtu8A:9 a=FfaGCDsud1wA:10 a=9gvnlMMaQFpL9xblJ6ne:22 Received: from mx3210.localdomain (70.50.7.94) by cmx-mtlrgo001.bell.net (5.8.716.03) (authenticated as dave.anglin@bell.net) id 61E9B8D000908B4A; Thu, 27 Jan 2022 17:33:42 -0500 Received: by mx3210.localdomain (Postfix, from userid 1000) id C4106220116; Thu, 27 Jan 2022 22:33:41 +0000 (UTC) Date: Thu, 27 Jan 2022 22:33:41 +0000 From: John David Anglin To: linux-parisc@vger.kernel.org Cc: Helge Deller , Deller , James Bottomley Subject: [PATCH] parisc: Fix sglist access in ccio-dma.c Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org This patch implements the same change to ccio-dma.c as to sba_iommu.c. This ensures that only the allocated entries of the sglist are accessed. Signed-off-by: John David Anglin diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index 059566f54429..9be007c9420f 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c @@ -1003,7 +1003,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; @@ -1011,6 +1011,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);