[PATCH 2/4] Bug Fix drivers/pci/intel-iommu.c: secure sg_next() calling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



sg_next() is called only when sg is not NULL. This solves a kernel panic on
some platforms (e.g. ia64).

Signed-off-by: Fenghua Yu <fenghua.yu@xxxxxxxxx>

---

 drivers/pci/intel-iommu.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index bec29ed..54ee63d 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1705,8 +1715,12 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
 		iov_pfn++;
 		pteval += VTD_PAGE_SIZE;
 		sg_res--;
-		if (!sg_res)
-			sg = sg_next(sg);
+		if (!sg_res) {
+			if (sg)
+				sg = sg_next(sg);
+			else
+				return 0;
+		}
 	}
 	return 0;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Sparc Linux]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux x86_64]     [Linux for Ham Radio]

  Powered by Linux