summaryrefslogtreecommitdiff
path: root/hw/usb/hcd-ehci-pci.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2015-03-18 17:33:47 +0800
committerGerd Hoffmann <kraxel@redhat.com>2015-03-20 08:50:12 +0100
commit4e289b1b62c8e271e3400317b4c3d98909093bc4 (patch)
treef24d7ddb4f9500b23f823015eade04f4414a68e6 /hw/usb/hcd-ehci-pci.c
parent88dd1b8d0063ff16c54dc19c8b52508a00108f50 (diff)
downloadqemu-4e289b1b62c8e271e3400317b4c3d98909093bc4.tar.gz
ehci: fix segfault when hot-unplugging ehci controller
When hot-unplugging the usb controllers (ehci/uhci), we have to clean all resouce of these devices, involved registered reset handler. Otherwise, it may cause NULL pointer access and/or segmentation fault if we reboot the guest os after hot-unplugging. Let's hook up reset via DeviceClass->reset() and drop the qemu_register_reset() call. Then Qemu will register and unregister the reset handler automatically. Cc: qemu-stable <qemu-stable@nongnu.org> Reported-by: Lidonglin <lidonglin@huawei.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/hcd-ehci-pci.c')
-rw-r--r--hw/usb/hcd-ehci-pci.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 4c80707f85..7afa5f9d67 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -101,6 +101,15 @@ static void usb_ehci_pci_exit(PCIDevice *dev)
}
}
+static void usb_ehci_pci_reset(DeviceState *dev)
+{
+ PCIDevice *pci_dev = PCI_DEVICE(dev);
+ EHCIPCIState *i = PCI_EHCI(pci_dev);
+ EHCIState *s = &i->ehci;
+
+ ehci_reset(s);
+}
+
static void usb_ehci_pci_write_config(PCIDevice *dev, uint32_t addr,
uint32_t val, int l)
{
@@ -143,6 +152,7 @@ static void ehci_class_init(ObjectClass *klass, void *data)
k->config_write = usb_ehci_pci_write_config;
dc->vmsd = &vmstate_ehci_pci;
dc->props = ehci_pci_properties;
+ dc->reset = usb_ehci_pci_reset;
}
static const TypeInfo ehci_pci_type_info = {