aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Deegan <Tim.Deegan@citrix.com>2011-05-24 08:21:01 +0100
committerTim Deegan <Tim.Deegan@citrix.com>2011-05-24 08:21:01 +0100
commitc33f6162196fec1f82c74fc7b7b3c4f4f0b073ed (patch)
tree6b67245ceeca8996577f5e19950fa50eb5cb3168
parent58f91af1df3a202c82c0bc1f111b49e7fb3e3204 (diff)
downloadxen-c33f6162196fec1f82c74fc7b7b3c4f4f0b073ed.tar.gz
xen-c33f6162196fec1f82c74fc7b7b3c4f4f0b073ed.tar.bz2
xen-c33f6162196fec1f82c74fc7b7b3c4f4f0b073ed.zip
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@citrix.com> 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@xen.org> xen-unstable changeset: 23370:2e6719425265 xen-unstable date: Mon May 23 18:35:04 2011 +0100
-rw-r--r--xen/drivers/passthrough/pci.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 3599e0c2ec..86f680d6a1 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -155,7 +155,10 @@ int pci_add_device(u8 bus, u8 devfn)
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 @@ out:
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 @@ int pci_add_device_ext(u8 bus, u8 devfn, struct pci_dev_info *info)
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);