[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 23/31] uhci: Don't crash on device disconnect
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 23/31] uhci: Don't crash on device disconnect |
Date: |
Thu, 1 Nov 2012 16:54:36 +0100 |
From: Hans de Goede <address@hidden>
My recent uhci cleanup series has introduced a regression, where
qemu sometimes crashes on a device disconnect. The problem is that
the uhci code never checked for a device not / no longer existing, instead
it was relying on usb_handle_packet accepting a NULL device.
But since we now pass usb_handle_packet q->ep->dev, rather then just
a local dev variable, we crash as q->ep == NULL due to the device no longer
existing.
This patch fixes this. Note that this patch also improves over
the old behavior were we would:
1) create a queue for the device
2) create an async for the packet
3) have usb_handle_packet fail
4) destroy the async
5) wait for the queue to be idle for 32 frames
6) destroy the queue
Which was rather sub-optimal.
Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/hcd-uhci.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index a06372b..f4b555a 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -896,6 +896,11 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q,
uint32_t qh_addr,
if (q == NULL) {
USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
+
+ if (ep == NULL) {
+ return uhci_handle_td_error(s, td, td_addr, USB_RET_NODEV,
+ int_mask);
+ }
q = uhci_queue_new(s, qh_addr, td, ep);
}
async = uhci_async_alloc(q, td_addr);
--
1.7.1
- [Qemu-devel] [PATCH 16/31] uhci: dynamic type generation, (continued)
- [Qemu-devel] [PATCH 16/31] uhci: dynamic type generation, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 31/31] usb-redir: Allow redirecting super speed devices to high speed controllers, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 30/31] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 24/31] usb: Add packet combining functions, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 14/31] usb/ehci: add sysbus variant, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 22/31] uhci: Add a uhci_handle_td_error() helper function, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 27/31] usb-redir: Add support for input pipelining, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 19/31] usb/ehci-pci: dynamic type generation, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 13/31] usb/ehci: split into multiple source files, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 15/31] xilinx_zynq: add USB controllers, Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 23/31] uhci: Don't crash on device disconnect,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 17/31] uhci: stick irq routing info into UHCIInfo too., Gerd Hoffmann, 2012/11/01
- [Qemu-devel] [PATCH 25/31] combined-packet: Add a workaround for Linux usbfs + live migration, Gerd Hoffmann, 2012/11/01