ehci: fix queue->dev null ptr dereference
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 21 Aug 2019 08:53:19 +0000 (10:53 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 22 Aug 2019 04:55:29 +0000 (06:55 +0200)
In case we don't have a device for an active queue, just skip
processing the queue (same we do for inactive queues) and log
a guest bug.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Message-id: 20190821085319.13711-1-kraxel@redhat.com

hw/usb/hcd-ehci.c

index 9ca7b87a8001af2bcbfd96db023743d540a1a21d..56ab2f457f4c139d9c38644fa1b5ae29a2b1dd5c 100644 (file)
@@ -1838,6 +1838,9 @@ static int ehci_state_fetchqtd(EHCIQueue *q)
             ehci_set_state(q->ehci, q->async, EST_EXECUTING);
             break;
         }
+    } else if (q->dev == NULL) {
+        ehci_trace_guest_bug(q->ehci, "no device attached to queue");
+        ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
     } else {
         p = ehci_alloc_packet(q);
         p->qtdaddr = q->qtdaddr;