[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] usb/ohci: Fix crash with when specifying too many n

From: Thomas Huth
Subject: [Qemu-devel] [PATCH] usb/ohci: Fix crash with when specifying too many num-ports
Date: Mon, 23 May 2016 11:23:07 +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 <address@hidden>
 hw/usb/hcd-ohci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index ffab561..16d9ff7 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1848,6 +1848,12 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState 
     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) {
         usb_frame_time = NANOSECONDS_PER_SECOND;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]