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

From: Fenghua Yu
Date: Tue Aug 04 2009 - 18:10:44 EST


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-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/