From 4e289b1b62c8e271e3400317b4c3d98909093bc4 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Wed, 18 Mar 2015 17:33:47 +0800 Subject: 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 Reported-by: Lidonglin Signed-off-by: Gonglei Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.h | 1 + 1 file changed, 1 insertion(+) (limited to 'hw/usb/hcd-ehci.h') diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 2bc259c..87b240f 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -325,6 +325,7 @@ extern const VMStateDescription vmstate_ehci; void usb_ehci_init(EHCIState *s, DeviceState *dev); void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp); void usb_ehci_unrealize(EHCIState *s, DeviceState *dev, Error **errp); +void ehci_reset(void *opaque); #define TYPE_PCI_EHCI "pci-ehci-usb" #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI) -- cgit v1.1