[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/17] xhci: Add a few missing checks for disconnect
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 01/17] xhci: Add a few missing checks for disconnected devices |
Date: |
Fri, 29 Nov 2013 09:06:05 +0100 |
From: Hans de Goede <address@hidden>
One of the reworks of qemu's usb core made changes to usb-port's disconnect
handling. Now ports with a device will always have a non 0 dev member, but
if the device is not attached (which is possible with usb redirection),
dev->attached will be 0.
So supplement all checks for dev to also check dev->attached, and add an
extra check in a path where a device check was completely missing.
This fixes various crashes (asserts triggering) I've been seeing when xhci
attached usb devices get disconnected at the wrong time.
Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/hcd-xhci.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 835f65e..c3377ee 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -1495,7 +1495,8 @@ static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned
int slotid,
}
if (!xhci->slots[slotid-1].uport ||
- !xhci->slots[slotid-1].uport->dev) {
+ !xhci->slots[slotid-1].uport->dev ||
+ !xhci->slots[slotid-1].uport->dev->attached) {
return CC_USB_TRANSACTION_ERROR;
}
@@ -1982,6 +1983,14 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int
slotid,
return;
}
+ /* If the device has been detached, but the guest has not noticed this
+ yet the 2 above checks will succeed, but we must NOT continue */
+ if (!xhci->slots[slotid - 1].uport ||
+ !xhci->slots[slotid - 1].uport->dev ||
+ !xhci->slots[slotid - 1].uport->dev->attached) {
+ return;
+ }
+
if (epctx->retry) {
XHCITransfer *xfer = epctx->retry;
@@ -2206,7 +2215,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci,
unsigned int slotid,
trace_usb_xhci_slot_address(slotid, uport->path);
dev = uport->dev;
- if (!dev) {
+ if (!dev || !dev->attached) {
fprintf(stderr, "xhci: port %s not connected\n", uport->path);
return CC_USB_TRANSACTION_ERROR;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/17] usb patch queue, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 02/17] xhci: add support for suspend/resume, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 01/17] xhci: Add a few missing checks for disconnected devices,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 13/17] ehci: implement port wakeup, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 11/17] usb: Add usb_device_alloc/free_streams, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 12/17] xhci: Call usb_device_alloc/free_streams, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 17/17] usb: move usb_{hi, lo} helpers to header file., Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 07/17] uas: Bounds check tags when using streams, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 14/17] Revert "usb-tablet: Don't claim wakeup capability for USB-2 version", Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 06/17] uas: Streams are numbered 1-y, rather then 0-x, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 15/17] trace-events: Clean up after removal of old usb-host code, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 08/17] uas: Fix response iu struct definition, Gerd Hoffmann, 2013/11/29
- [Qemu-devel] [PATCH 09/17] uas: s/ui/iu/, Gerd Hoffmann, 2013/11/29