From: Sowmini Varadhan Date: Fri, 18 Sep 2015 11:49:50 +0000 (+0530) Subject: lib/iommu-common.c: do not try to deref a null iommu->lazy_flush() pointer when n... X-Git-Tag: v4.1.12-92~270^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4d16d5529b8e0e7afff8d5e6f1753c23d4e1fd30;p=users%2Fjedix%2Flinux-maple.git lib/iommu-common.c: do not try to deref a null iommu->lazy_flush() pointer when n < pool->hint The check for invoking iommu->lazy_flush() from iommu_tbl_range_alloc() has to be refactored so that we only call ->lazy_flush() if it is non-null. I had a sparc kernel that was crashing when I was trying to process some very large perf.data files- the crash happens when the scsi driver calls into dma_4v_map_sg and thus the iommu_tbl_range_alloc(). Signed-off-by: Sowmini Varadhan Cc: Benjamin Herrenschmidt Cc: Guenter Roeck Cc: David S. Miller Cc: Signed-off-by: Andrew Morton (cherry picked from commit 02fa305981f7e2934173604f22789918cdaa6e3b) (cherry picked from commit ca2de477dfdcfa0a1f32f95a701e81467438d3f4) Signed-off-by: Allen Pais --- diff --git a/lib/iommu-common.c b/lib/iommu-common.c index ff19f66d3f7f..b1c93e94ca7a 100644 --- a/lib/iommu-common.c +++ b/lib/iommu-common.c @@ -21,8 +21,7 @@ static DEFINE_PER_CPU(unsigned int, iommu_hash_common); static inline bool need_flush(struct iommu_map_table *iommu) { - return (iommu->lazy_flush != NULL && - (iommu->flags & IOMMU_NEED_FLUSH) != 0); + return ((iommu->flags & IOMMU_NEED_FLUSH) != 0); } static inline void set_flush(struct iommu_map_table *iommu) @@ -211,7 +210,8 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, goto bail; } } - if (n < pool->hint || need_flush(iommu)) { + if (iommu->lazy_flush && + (n < pool->hint || need_flush(iommu))) { clear_flush(iommu); iommu->lazy_flush(iommu); }