summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-03-17 19:44:46 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-03-20 18:36:40 +0100
commit0c8d84f3eedd22ef50b6a22b27398cd1b2b4a925 (patch)
tree4c176b2b22789150c5376a87859d2d34a5ce400e
parentf0ff7587b7f0341e9771d8679e37bc976872f57e (diff)
downloadqemu-0c8d84f3eedd22ef50b6a22b27398cd1b2b4a925.tar.gz
usbdump: fix endpoint lookup
bNumEndpoints specify the number of endpoints in the endpoint descriptor. When the mouse endpoint was tried (EP2), it triggered this assertion because there is only one endpoint for the interface. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--hw/usb/dump.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/hw/usb/dump.c b/hw/usb/dump.c
index 6d35d46963..b0209c1f02 100644
--- a/hw/usb/dump.c
+++ b/hw/usb/dump.c
@@ -157,11 +157,15 @@ static uint8_t get_ep_interval(USBEndpoint *ep)
assert(ep->ifnum < dev->ninterfaces);
const USBDescIface *iface = dev->ifaces[ep->ifnum];
- /* EP0 is defined as the Default control pipe */
- assert(ep->nr > 0);
- assert(ep->nr <= iface->bNumEndpoints);
- const USBDescEndpoint *uep = iface->eps + ep->nr - 1;
-
+ const USBDescEndpoint *uep = NULL;
+ int i;
+ for (i = 0; i < iface->bNumEndpoints; ++i) {
+ if ((iface->eps[i].bEndpointAddress & 15) == ep->nr) {
+ uep = &iface->eps[i];
+ break;
+ }
+ }
+ assert(uep != NULL);
return uep->bInterval;
}