From f25c0b30edd7ada489626f0cec4d06ca5e46d471 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 17 Mar 2014 19:44:46 +0100 Subject: 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 --- hw/usb/dump.c | 14 +++++++++----- 1 file 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; } -- cgit v1.2.1