Skip to contentSkip to conversation

pci: fix

GIT PULL Applied Michael S. Tsirkin 2 participants 3 messages Apr 4, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit 87cc4c61020addea6a001b94b662596b1896d1b3:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-04-04 11:40:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 193982c6f9424779b53a168fe32ebc30a776cbf1:

pci: Only unmap bus_master_enabled_region if was added previously (2017-04-04 18:32:25 +0300)

----------------------------------------------------------------
pci: fix

A single bugfix for a error handling issue in pci.

----------------------------------------------------------------
Alexey Kardashevskiy (1):
pci: Only unmap bus_master_enabled_region if was added previously

 hw/pci/pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/1] pci: Only unmap bus_master_enabled_region if was added previously

From: Alexey Kardashevskiy <[email protected]>

Normally pci_init_bus_master() would be called either via bus->machine_done.notify or directly from do_pci_register_device().

However if a device's realize() failed, pci_init_bus_master() is not called, and do_pci_unregister_device() fails on memory_region_del_subregion() as it was not mapped.

This adds a check that subregion was mapped before unmapping it.

---
 hw/pci/pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/pci/pci.c +4 -2
index bd8043c..259483b 100644
@@ -869,8 +869,10 @@ static void do_pci_unregister_device(PCIDevice *pci_dev)
     pci_dev->bus->devices[pci_dev->devfn] = NULL;
     pci_config_free(pci_dev);
 
-    memory_region_del_subregion(&pci_dev->bus_master_container_region,
-                                &pci_dev->bus_master_enable_region);
+    if (memory_region_is_mapped(&pci_dev->bus_master_enable_region)) {
+        memory_region_del_subregion(&pci_dev->bus_master_container_region,
+                                    &pci_dev->bus_master_enable_region);
+    }
     address_space_destroy(&pci_dev->bus_master_as);
 }
 
Signature · 1 line
MST
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 15 lines · Michael S. Tsirkin

The following changes since commit 87cc4c61020addea6a001b94b662596b1896d1b3:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-04-04 11:40:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 193982c6f9424779b53a168fe32ebc30a776cbf1:

pci: Only unmap bus_master_enabled_region if was added previously (2017-04-04 18:32:25 +0300)

----------------------------------------------------------------
pci: fix

Quoted 7 lines

A single bugfix for a error handling issue in pci.

----------------------------------------------------------------
Alexey Kardashevskiy (1):
pci: Only unmap bus_master_enabled_region if was added previously

Applied, thanks.

-- PMM