]> git.proxmox.com Git - mirror_qemu.git/commit
pci: Only unmap bus_master_enabled_region if was added previously
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Fri, 31 Mar 2017 04:47:11 +0000 (15:47 +1100)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 4 Apr 2017 15:32:25 +0000 (18:32 +0300)
commit193982c6f9424779b53a168fe32ebc30a776cbf1
tree78d3f3f3cd8bff50a01c3052e45ec5b61b117efe
parent87cc4c61020addea6a001b94b662596b1896d1b3
pci: Only unmap bus_master_enabled_region if was added previously

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.

Fixes: c53598ed18e4 ("pci: Add missing drop of bus master AS reference")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: John Snow <jsnow@redhat.com>
hw/pci/pci.c