Skip to contentSkip to conversation

ehci: add sanity check for maxframes

PATCH In review Gerd Hoffmann 2 participants 2 messages Jul 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ehci: add sanity check for maxframes

---
 hw/usb/hcd-ehci.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/usb/hcd-ehci.c +5 -0
index 73090e01ad..604912cb3e 100644
@@ -2483,6 +2483,11 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
                    NB_PORTS);
         return;
     }
+    if (s->maxframes < 8 || s->maxframes > 512)  {
+        error_setg(errp, "maxframes %d out if range (8 .. 512)",
+                   s->maxframes);
+        return;
+    }
 
     usb_bus_new(&s->bus, sizeof(s->bus), s->companion_enable ?
                 &ehci_bus_ops_companion : &ehci_bus_ops_standalone, dev);
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Gerd Hoffmann
---
 hw/usb/hcd-ehci.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/usb/hcd-ehci.c +0 -0
index 73090e01ad..604912cb3e 100644

hw/usb/hcd-ehci.c void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) · line 2488

Quoted 6 lines
hw/usb/hcd-ehci.c +3 -0
@@ -2483,6 +2483,11 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
                    NB_PORTS);
         return;
     }
+    if (s->maxframes < 8 || s->maxframes > 512)  {
+        error_setg(errp, "maxframes %d out if range (8 .. 512)",
+                   s->maxframes);

Typo: should be "of".

Quoted 7 lines
hw/usb/hcd-ehci.c +2 -1
+        return;
+    }
 
     usb_bus_new(&s->bus, sizeof(s->bus), s->companion_enable ?
                 &ehci_bus_ops_companion : &ehci_bus_ops_standalone, dev);
--

2.9.3

Otherwise

Do we want something similar for hcd-uhci just for consistency?

thanks
-- PMM