summary refs log tree commit diff stats
path: root/hw/usb/hcd-musb.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/hcd-musb.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/hcd-musb.c')
-rw-r--r--hw/usb/hcd-musb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
index d70a91a58c..85d7796554 100644
--- a/hw/usb/hcd-musb.c
+++ b/hw/usb/hcd-musb.c
@@ -628,11 +628,11 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep,
 
     /* A wild guess on the FADDR semantics... */
     dev = usb_find_device(&s->port, ep->faddr[idx]);
-    uep = usb_ep_get(dev, pid, ep->type[idx] & 0xf);
-    id = pid;
-    if (uep) {
-        id |= (dev->addr << 16) | (uep->nr << 8);
+    if (dev == NULL) {
+        return;
     }
+    uep = usb_ep_get(dev, pid, ep->type[idx] & 0xf);
+    id = pid | (dev->addr << 16) | (uep->nr << 8);
     usb_packet_setup(&ep->packey[dir].p, pid, uep, 0, id, false, true);
     usb_packet_addbuf(&ep->packey[dir].p, ep->buf[idx], len);
     ep->packey[dir].ep = ep;