qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/9] Dealing with Null devices in usb_ep_get()
@ 2019-02-06 13:36 Liam Merwick
  2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 1/9] usb: rearrange usb_ep_get() Liam Merwick
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Liam Merwick @ 2019-02-06 13:36 UTC (permalink / raw)
  To: kraxel, qemu-devel; +Cc: liam.merwick, darren.kenny

This series is in response to feedback from Gerd Hoffman (below) on 
<1548859022-3969-1-git-send-email-liam.merwick@oracle.com>

Instead of checking if usb_ep_get() returns NULL, ensure it never is passed
a NULL device.

===

The usb device emulation (hw/usb/dev-*.c) never ever calls usb_ep_get()
with dev == NULL.  There are some places in usb host adapter emulation
(hw/usb/hcd-*) which might do this.  uhci for example has this ...

	[ ... ]
        USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
        USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);

        if (ep == NULL) {
	[ ... ]

... and uhci_find_device can return NULL.

So, I'd suggest to check all usb_ep_get() callers, fix them if needed,
then remove the 'if (dev== NULL)' check in usb_ep_get() and add the
assert() instead.

===

Passes QEMU 'make check' and kvm-unit-tests


Liam Merwick (9):
  usb: rearrange usb_ep_get()
  xhci: add asserts to help with static code analysis
  xhci: check device is not NULL before calling usb_ep_get()
  ehci: check device is not NULL before calling usb_ep_get()
  ohci: check device is not NULL before calling usb_ep_get()
  uhci: check device is not NULL before calling usb_ep_get()
  usb: check device is not NULL before calling usb_ep_get()
  usb: add device checks before redirector calls to usb_ep_get()
  usb: remove unnecessary NULL device check from usb_ep_get()

 hw/usb/core.c     | 6 ++----
 hw/usb/hcd-ehci.c | 7 +++++--
 hw/usb/hcd-musb.c | 8 ++++----
 hw/usb/hcd-ohci.c | 8 ++++++++
 hw/usb/hcd-uhci.c | 8 +++++---
 hw/usb/hcd-xhci.c | 6 ++++--
 hw/usb/redirect.c | 3 ++-
 7 files changed, 30 insertions(+), 16 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-02-08 10:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-06 13:36 [Qemu-devel] [PATCH v2 0/9] Dealing with Null devices in usb_ep_get() Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 1/9] usb: rearrange usb_ep_get() Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 2/9] xhci: add asserts to help with static code analysis Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 3/9] xhci: check device is not NULL before calling usb_ep_get() Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 4/9] ehci: " Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 5/9] ohci: " Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 6/9] uhci: " Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 7/9] usb: " Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 8/9] usb: add device checks before redirector calls to usb_ep_get() Liam Merwick
2019-02-06 13:36 ` [Qemu-devel] [PATCH v2 9/9] usb: remove unnecessary NULL device check from usb_ep_get() Liam Merwick
2019-02-08 10:18 ` [Qemu-devel] [PATCH v2 0/9] Dealing with Null devices in usb_ep_get() Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).