提交 e87fd1e6 编写于 作者: L Liam Merwick 提交者: Gerd Hoffmann

usb: check device is not NULL before calling usb_ep_get()

In musb_packet(), the call to usb_find_device() can return NULL
if it doesn't find a device matching 'addr' so explicitly check
the return value before passing it to usb_ep_get().  This then
allows the subsequent calculation of 'id' to be streamlined.
Signed-off-by: NLiam Merwick <liam.merwick@oracle.com>
Message-id: 1549460216-25808-8-git-send-email-liam.merwick@oracle.com
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 ff668537
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册