]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
usb/ohci: Fix crash with when specifying too many num-ports
authorThomas Huth <thuth@redhat.com>
Mon, 23 May 2016 09:23:07 +0000 (11:23 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 23 May 2016 12:59:40 +0000 (14:59 +0200)
QEMU currently crashes when an OHCI controller is instantiated with
too many ports, e.g. "-device pci-ohci,num-ports=100,masterbus=1".
Thus add a proper check in usb_ohci_init() to make sure that we
do not use more than OHCI_MAX_PORTS = 15 ports here.

Ticket: https://bugs.launchpad.net/qemu/+bug/1581308
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-id: 1463995387-11710-1-git-send-email-thuth@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/hcd-ohci.c

index ffab561cf6443994a0f9d6253fd6d705ea0016c5..16d9ff7b4b267040123cf6e205ee54470f1c8242 100644 (file)
@@ -1848,6 +1848,12 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
 
     ohci->as = as;
 
+    if (num_ports > OHCI_MAX_PORTS) {
+        error_setg(errp, "OHCI num-ports=%d is too big (limit is %d ports)",
+                   num_ports, OHCI_MAX_PORTS);
+        return;
+    }
+
     if (usb_frame_time == 0) {
 #ifdef OHCI_TIME_WARP
         usb_frame_time = NANOSECONDS_PER_SECOND;