From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753310AbbIQBvA (ORCPT ); Wed, 16 Sep 2015 21:51:00 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:51347 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752952AbbIQBu7 (ORCPT ); Wed, 16 Sep 2015 21:50:59 -0400 Date: Wed, 16 Sep 2015 21:50:43 -0400 From: Sowmini Varadhan To: linux-kernel@vger.kernel.org Cc: sowmini.varadhan@oracle.com, benh@kernel.crashing.org, akpm@linux-foundation.org, linux@roeck-us.net, davem@davemloft.net Subject: [PATCH] iommu-common: Do not try to deref a null iommu->lazy_flush() pointer when n < pool->hint Message-ID: <20150917015043.GC13020@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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