Commit 800d7454 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: usbip: fix nonconforming hub descriptor

commit ec963b41 upstream.

Fix up the root-hub descriptor to accommodate the variable-length
DeviceRemovable and PortPwrCtrlMask fields, while marking all ports as
removable (and leaving the reserved bit zero unset).

Also add a build-time constraint on VHCI_HC_PORTS which must never be
greater than USB_MAXCHILDREN (but this was only enforced through a
KConfig constant).

This specifically fixes the descriptor layout whenever VHCI_HC_PORTS is
greater than seven (default is 8).

Fixes: 04679b34 ("Staging: USB/IP: add client driver")
Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net>
Cc: Valentina Manea <valentina.manea.m@gmail.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Acked-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
[ johan: backport to v4.4, which uses VHCI_NPORTS ]
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 525e496a
...@@ -215,14 +215,19 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) ...@@ -215,14 +215,19 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
static inline void hub_descriptor(struct usb_hub_descriptor *desc) static inline void hub_descriptor(struct usb_hub_descriptor *desc)
{ {
int width;
memset(desc, 0, sizeof(*desc)); memset(desc, 0, sizeof(*desc));
desc->bDescriptorType = USB_DT_HUB; desc->bDescriptorType = USB_DT_HUB;
desc->bDescLength = 9;
desc->wHubCharacteristics = cpu_to_le16( desc->wHubCharacteristics = cpu_to_le16(
HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM); HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = VHCI_NPORTS; desc->bNbrPorts = VHCI_NPORTS;
desc->u.hs.DeviceRemovable[0] = 0xff; BUILD_BUG_ON(VHCI_NPORTS > USB_MAXCHILDREN);
desc->u.hs.DeviceRemovable[1] = 0xff; width = desc->bNbrPorts / 8 + 1;
desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * width;
memset(&desc->u.hs.DeviceRemovable[0], 0, width);
memset(&desc->u.hs.DeviceRemovable[width], 0xff, width);
} }
static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment