summary refs log tree commit diff stats
path: root/hw/usb/core.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-02-21 09:41:11 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-02-21 09:41:11 +0000
commit039e406603852e9ddb23b5965b6956d42304bc55 (patch)
tree6a706ed412d6546a25077931d14daae02c75eedb /hw/usb/core.c
parent2e68b8620637a4ee8c79b5724144b726af1e261b (diff)
parent7011baece29d0e197c54c4e57326ba88e67a4949 (diff)
downloadfocaccia-qemu-039e406603852e9ddb23b5965b6956d42304bc55.tar.gz
focaccia-qemu-039e406603852e9ddb23b5965b6956d42304bc55.zip
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20190220-pull-request' into staging
usb: usb_ep_get() fixes

# gpg: Signature made Wed 20 Feb 2019 11:13:32 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/usb-20190220-pull-request:
  usb: remove unnecessary NULL device check from usb_ep_get()
  usb: add device checks before redirector calls to usb_ep_get()
  usb: check device is not NULL before calling usb_ep_get()
  uhci: check device is not NULL before calling usb_ep_get()
  ohci: check device is not NULL before calling usb_ep_get()
  ehci: check device is not NULL before calling usb_ep_get()
  xhci: check device is not NULL before calling usb_ep_get()
  xhci: add asserts to help with static code analysis
  usb: rearrange usb_ep_get()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/usb/core.c')
-rw-r--r--hw/usb/core.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 241ae66b15..8fbd9c7d57 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -717,15 +717,13 @@ struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
 {
     struct USBEndpoint *eps;
 
-    if (dev == NULL) {
-        return NULL;
-    }
-    eps = (pid == USB_TOKEN_IN) ? dev->ep_in : dev->ep_out;
+    assert(dev != NULL);
     if (ep == 0) {
         return &dev->ep_ctl;
     }
     assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);
     assert(ep > 0 && ep <= USB_MAX_ENDPOINTS);
+    eps = (pid == USB_TOKEN_IN) ? dev->ep_in : dev->ep_out;
     return eps + ep - 1;
 }