diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-03-17 19:44:46 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-03-17 19:44:46 +0100 |
commit | f25c0b30edd7ada489626f0cec4d06ca5e46d471 (patch) | |
tree | 2731524dca081e2293f7d5e5c35dbf877cc60dfa | |
parent | de5c8d947b3e197e4f063134ae28c7d29118f95d (diff) | |
download | qemu-f25c0b30edd7ada489626f0cec4d06ca5e46d471.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.c | 14 |
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; } |