[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-4.0-testing] drivers/passthrough: fix error paths in pci_add_device*()



# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxx>
# Date 1306221661 -3600
# Node ID 7a71574b025aa762fbce266fa7de39383aac606a
# Parent  f5e4ec006ab936e22955254487ce82aad6cdf5e5
drivers/passthrough: fix error paths in pci_add_device*()

When a device can't be allocated to dom0 by the IOMMU, don't leave
dom0 in the "domain" field.  It causes pci_remove_device()
to crash trying to remove the dev from the domain's list of devices
(and was probably the wrong thing to do anyway).

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
xen-unstable changeset:   23371:4326bcd88b33
xen-unstable date:        Mon May 23 18:35:32 2011 +0100

drivers/passthrough: Revert 23352:ea48976517af -- incorrect bugfix.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   23370:2e6719425265
xen-unstable date:        Mon May 23 18:35:04 2011 +0100
---


diff -r f5e4ec006ab9 -r 7a71574b025a xen/drivers/passthrough/pci.c
--- a/xen/drivers/passthrough/pci.c     Tue May 24 08:20:39 2011 +0100
+++ b/xen/drivers/passthrough/pci.c     Tue May 24 08:21:01 2011 +0100
@@ -155,7 +155,10 @@
         pdev->domain = dom0;
         ret = iommu_add_device(pdev);
         if ( ret )
+        {
+            pdev->domain = NULL;
             goto out;
+        }
 
         list_add(&pdev->domain_list, &dom0->arch.pdev_list);
         pci_enable_acs(pdev);
@@ -170,11 +173,11 @@
 
 int pci_remove_device(u8 bus, u8 devfn)
 {
-    struct pci_dev *pdev, *tmp;
+    struct pci_dev *pdev;
     int ret = -ENODEV;
 
     spin_lock(&pcidevs_lock);
-    list_for_each_entry_safe ( pdev, tmp, &alldevs_list, alldevs_list )
+    list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
         {
             ret = iommu_remove_device(pdev);
@@ -219,7 +222,10 @@
         pdev->domain = dom0;
         ret = iommu_add_device(pdev);
         if ( ret )
+        {
+            pdev->domain = NULL;
             goto out;
+        }
 
         list_add(&pdev->domain_list, &dom0->arch.pdev_list);
         pci_enable_acs(pdev);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.