Skip to content

Dealing with Null devices in usb_ep_get()

Liam Merwick qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 1 replyIn review
  2. v12 patches 4 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9usb: rearrange usb_ep_get()hw/usb/core.c+1 -10 replies
2/9xhci: add asserts to help with static code analysishw/usb/hcd-xhci.c+2 -00 replies
3/9xhci: check device is not NULL before calling usb_ep_get()hw/usb/hcd-xhci.c+2 -20 replies
4/9ehci: check device is not NULL before calling usb_ep_get()hw/usb/hcd-ehci.c+5 -20 replies
5/9ohci: check device is not NULL before calling usb_ep_get()hw/usb/hcd-ohci.c+8 -00 replies
6/9uhci: check device is not NULL before calling usb_ep_get()hw/usb/hcd-uhci.c+5 -30 replies
7/9usb: check device is not NULL before calling usb_ep_get()hw/usb/hcd-musb.c+4 -40 replies
8/9usb: add device checks before redirector calls to usb_ep_get()hw/usb/redirect.c+2 -10 replies
9/9usb: remove unnecessary NULL device check from usb_ep_get()hw/usb/core.c+1 -30 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchDarren KennyMark KandaAmeya More
1/9R-b R-b R-b
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/9] Dealing with Null devices in usb_ep_get()

This series is in response to feedback from Gerd Hoffman (below) on <[email protected]>

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(-)
Signature · 1 line
1.8.3.1