From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: [PATCH] iommu/vt-d: Do not BUG_ON in intel_unmap if no domain Date: Mon, 4 Aug 2014 13:23:06 +0200 Message-ID: <1407151386-16467-1-git-send-email-joro@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Cc: Joerg Roedel , David Woodhouse , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jiang Liu List-Id: iommu@lists.linux-foundation.org From: Joerg Roedel This BUG_ON is easy to trigger with device-hotplug (e.g. SR-IOV). The device_notifier function in the Intel IOMMU driver listens to the BUS_NOTIFY_DEL_DEVICE event and frees the domain for the device if it is reveived. But this event is triggered before the device driver is unbound from the device. When the driver core actually removes the device the driver may release pending DMA resources, which ends up in intel_unmap and triggers the BUG_ON. Not listening to BUS_NOTIFY_DEL_DEVICE would cause resource leakage with devices that have never been assigned to any driver, so fix this issue by just making unmap a nop when the domain is already released. Cc: Jiang Liu Cc: David Woodhouse Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index d1f5caa..7d689d7 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3196,7 +3196,8 @@ static void intel_unmap(struct device *dev, dma_addr_t dev_addr) return; domain = find_domain(dev); - BUG_ON(!domain); + if (!domain) + return; iommu = domain_get_iommu(domain); -- 1.9.1