public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu-common: Do not try to deref a null iommu->lazy_flush() pointer when n < pool->hint
@ 2015-09-17  1:50 Sowmini Varadhan
  2015-09-17 21:26 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Sowmini Varadhan @ 2015-09-17  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: sowmini.varadhan, benh, akpm, linux, davem

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.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
---
 lib/iommu-common.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/iommu-common.c b/lib/iommu-common.c
index ff19f66..b1c93e9 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);
 	}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-17 21:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-17  1:50 [PATCH] iommu-common: Do not try to deref a null iommu->lazy_flush() pointer when n < pool->hint Sowmini Varadhan
2015-09-17 21:26 ` Andrew Morton
2015-09-17 21:32   ` Sowmini Varadhan
2015-09-17 21:41     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox