mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
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>
This commit is contained in:
parent
88dd1b8d00
commit
4e289b1b62
4 changed files with 22 additions and 2 deletions
|
@ -42,6 +42,15 @@ static void usb_ehci_sysbus_realize(DeviceState *dev, Error **errp)
|
|||
sysbus_init_irq(d, &s->irq);
|
||||
}
|
||||
|
||||
static void usb_ehci_sysbus_reset(DeviceState *dev)
|
||||
{
|
||||
SysBusDevice *d = SYS_BUS_DEVICE(dev);
|
||||
EHCISysBusState *i = SYS_BUS_EHCI(d);
|
||||
EHCIState *s = &i->ehci;
|
||||
|
||||
ehci_reset(s);
|
||||
}
|
||||
|
||||
static void ehci_sysbus_init(Object *obj)
|
||||
{
|
||||
SysBusDevice *d = SYS_BUS_DEVICE(obj);
|
||||
|
@ -70,6 +79,7 @@ static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
|
|||
dc->realize = usb_ehci_sysbus_realize;
|
||||
dc->vmsd = &vmstate_ehci_sysbus;
|
||||
dc->props = ehci_sysbus_properties;
|
||||
dc->reset = usb_ehci_sysbus_reset;
|
||||
set_bit(DEVICE_CATEGORY_USB, dc->categories);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue