diff mbox

intel-iommu: Fix lookup in add device

Message ID 20121113172144.6783.37724.stgit@bling.home
State Not Applicable
Headers show

Commit Message

Alex Williamson Nov. 13, 2012, 5:22 p.m. UTC
We can't assume this device exists, fall back to the bridge itself.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Tested-by: Matthew Thode <prometheanfire@gentoo.org>
Cc: stable@vger.kernel.org
---
 drivers/iommu/intel-iommu.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Matthew Thode Nov. 13, 2012, 6:12 p.m. UTC | #1
On 11/13/2012 11:22 AM, Alex Williamson wrote:
> We can't assume this device exists, fall back to the bridge itself.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Tested-by: Matthew Thode <prometheanfire@gentoo.org>
> Cc: stable@vger.kernel.org
> ---
>  drivers/iommu/intel-iommu.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index d4a4cd4..0badfa4 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -4108,7 +4108,7 @@ static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
>  static int intel_iommu_add_device(struct device *dev)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev);
> -	struct pci_dev *bridge, *dma_pdev;
> +	struct pci_dev *bridge, *dma_pdev = NULL;
>  	struct iommu_group *group;
>  	int ret;
>  
> @@ -4122,7 +4122,7 @@ static int intel_iommu_add_device(struct device *dev)
>  			dma_pdev = pci_get_domain_bus_and_slot(
>  						pci_domain_nr(pdev->bus),
>  						bridge->subordinate->number, 0);
> -		else
> +		if (!dma_pdev)
>  			dma_pdev = pci_dev_get(bridge);
>  	} else
>  		dma_pdev = pci_dev_get(pdev);
> 

I've tested this and it works just fine.
Joerg Roedel Nov. 17, 2012, 12:27 p.m. UTC | #2
On Tue, Nov 13, 2012 at 10:22:03AM -0700, Alex Williamson wrote:
> We can't assume this device exists, fall back to the bridge itself.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Tested-by: Matthew Thode <prometheanfire@gentoo.org>
> Cc: stable@vger.kernel.org

Applied to iommu/fixes, thanks.

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index d4a4cd4..0badfa4 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4108,7 +4108,7 @@  static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
 static int intel_iommu_add_device(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pci_dev *bridge, *dma_pdev;
+	struct pci_dev *bridge, *dma_pdev = NULL;
 	struct iommu_group *group;
 	int ret;
 
@@ -4122,7 +4122,7 @@  static int intel_iommu_add_device(struct device *dev)
 			dma_pdev = pci_get_domain_bus_and_slot(
 						pci_domain_nr(pdev->bus),
 						bridge->subordinate->number, 0);
-		else
+		if (!dma_pdev)
 			dma_pdev = pci_dev_get(bridge);
 	} else
 		dma_pdev = pci_dev_get(pdev);