[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH] usb: fix segfault when hot-unplugging usb host ada
From: |
arei.gonglei |
Subject: |
[Qemu-stable] [PATCH] usb: fix segfault when hot-unplugging usb host adapter |
Date: |
Tue, 17 Mar 2015 19:28:31 +0800 |
From: Gonglei <address@hidden>
When hot-unplugging the usb controllers (ehci/uhci),
we have to clean all resouce of these devices,
involed registered reset handler. Otherwise, it
may cause NULL pointer access and/or segmentation fault
if we reboot the guest os after hot-unplugging.
Cc: qemu-stable <address@hidden>
Reported-by: Lidonglin <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
hw/usb/hcd-ehci.c | 1 +
hw/usb/hcd-ohci.c | 1 +
hw/usb/hcd-uhci.c | 2 ++
3 files changed, 4 insertions(+)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index ccf54b6..5be41f8 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2495,6 +2495,7 @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev,
Error **errp)
memory_region_del_subregion(&s->mem, &s->mem_opreg);
memory_region_del_subregion(&s->mem, &s->mem_ports);
+ qemu_unregister_reset(ehci_reset, s);
usb_bus_release(&s->bus);
if (s->vmstate) {
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index a0d478e..840d254 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1949,6 +1949,7 @@ static void usb_ohci_exit(PCIDevice *dev)
if (!ohci->masterbus) {
usb_bus_release(&s->bus);
}
+ qemu_register_reset(ohci_reset, ohci);
}
#define TYPE_SYSBUS_OHCI "sysbus-ohci"
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index f903de7..70ad52a 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1274,6 +1274,8 @@ static void usb_uhci_exit(PCIDevice *dev)
if (!s->masterbus) {
usb_bus_release(&s->bus);
}
+
+ qemu_unregister_reset(uhci_reset, s);
}
static Property uhci_properties_companion[] = {
--
1.7.12.4
- [Qemu-stable] [PATCH] usb: fix segfault when hot-unplugging usb host adapter,
arei.gonglei <=