[Qemu-devel] [PATCH] ehci: add sanity check for maxframes

Gerd Hoffmann posted 1 patch 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170703111549.10924-1-kraxel@redhat.com
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
hw/usb/hcd-ehci.c | 5 +++++
1 file changed, 5 insertions(+)
[Qemu-devel] [PATCH] ehci: add sanity check for maxframes
Posted by Gerd Hoffmann 6 years, 9 months ago
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-ehci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 73090e01ad..604912cb3e 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -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);
-- 
2.9.3


Re: [Qemu-devel] [PATCH] ehci: add sanity check for maxframes
Posted by Peter Maydell 6 years, 9 months ago
On 3 July 2017 at 12:15, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/usb/hcd-ehci.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> index 73090e01ad..604912cb3e 100644
> --- a/hw/usb/hcd-ehci.c
> +++ b/hw/usb/hcd-ehci.c
> @@ -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".

> +        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
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

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

thanks
-- PMM