From: Alex Williamson <alex.williamson@redhat.com>
To: mst@redhat.com
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] pci: Unregister BARs before device exit
Date: Tue, 03 Jul 2012 22:39:34 -0600 [thread overview]
Message-ID: <20120704043933.19100.80886.stgit@bling.home> (raw)
In-Reply-To: <20120704041748.19100.95271.stgit@bling.home>
BARs are registered in init functions from memory regions created
by the drivers. Exit functions destroy those memory regions.
By unregistering the io regions after exit(), we're calling
memory_region_del_subregion on freed memory. Don't do that. The
option rom comes along for the ride because it's more symmetric
to how it's created.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/pci.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 8934722..1fc73f8 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -875,12 +875,13 @@ static int pci_unregister_device(DeviceState *dev)
PCIDevice *pci_dev = PCI_DEVICE(dev);
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
+ pci_unregister_io_regions(pci_dev);
+ pci_del_option_rom(pci_dev);
+
if (pc->exit) {
pc->exit(pci_dev);
}
- pci_unregister_io_regions(pci_dev);
- pci_del_option_rom(pci_dev);
do_pci_unregister_device(pci_dev);
return 0;
}
next prev parent reply other threads:[~2012-07-04 4:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-04 4:39 [Qemu-devel] [PATCH 0/2] pci: exit path cleanup and fix Alex Williamson
2012-07-04 4:39 ` [Qemu-devel] [PATCH 1/2] pci: convert PCIUnregisterFunc to void Alex Williamson
2012-07-04 4:39 ` Alex Williamson [this message]
2012-07-04 8:22 ` [Qemu-devel] [PATCH 0/2] pci: exit path cleanup and fix Paolo Bonzini
2012-07-04 12:47 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120704043933.19100.80886.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).