]> git.proxmox.com Git - qemu.git/commitdiff
usb-ehci: sanity-check iso xfers
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 27 Feb 2012 10:23:08 +0000 (11:23 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 27 Feb 2012 12:37:36 +0000 (13:37 +0100)
This patch adds a sanity check to itd processing to make sure the
endpoint addressed by the guest is actually an iso endpoint.  Also
verify that usb drivers don't return USB_RET_ASYNC which is illegal for
iso xfers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-ehci.c

index b9da26ada8041c7426f5c1a5d581e5c775741cf7..048eb7663e1989c05857789835250b2e7b6585bb 100644 (file)
@@ -1459,12 +1459,16 @@ static int ehci_process_itd(EHCIState *ehci,
 
             dev = ehci_find_device(ehci, devaddr);
             ep = usb_ep_get(dev, pid, endp);
-            usb_packet_setup(&ehci->ipacket, pid, ep);
-            usb_packet_map(&ehci->ipacket, &ehci->isgl);
-
-            ret = usb_handle_packet(dev, &ehci->ipacket);
-
-            usb_packet_unmap(&ehci->ipacket);
+            if (ep->type == USB_ENDPOINT_XFER_ISOC) {
+                usb_packet_setup(&ehci->ipacket, pid, ep);
+                usb_packet_map(&ehci->ipacket, &ehci->isgl);
+                ret = usb_handle_packet(dev, &ehci->ipacket);
+                assert(ret != USB_RET_ASYNC);
+                usb_packet_unmap(&ehci->ipacket);
+            } else {
+                DPRINTF("ISOCH: attempt to addess non-iso endpoint\n");
+                ret = USB_RET_NAK;
+            }
             qemu_sglist_destroy(&ehci->isgl);
 
 #if 0