Skip to content

Commit 800d745

Browse files
jhovoldgregkh
authored andcommitted
USB: usbip: fix nonconforming hub descriptor
commit ec963b412a54aac8e527708ecad06a6988a86fb4 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: 04679b3 ("Staging: USB/IP: add client driver") Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net> Cc: Valentina Manea <valentina.manea.m@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> [ johan: backport to v4.4, which uses VHCI_NPORTS ] Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 525e496 commit 800d745

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/usb/usbip/vhci_hcd.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,19 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
215215

216216
static inline void hub_descriptor(struct usb_hub_descriptor *desc)
217217
{
218+
int width;
219+
218220
memset(desc, 0, sizeof(*desc));
219221
desc->bDescriptorType = USB_DT_HUB;
220-
desc->bDescLength = 9;
221222
desc->wHubCharacteristics = cpu_to_le16(
222223
HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
224+
223225
desc->bNbrPorts = VHCI_NPORTS;
224-
desc->u.hs.DeviceRemovable[0] = 0xff;
225-
desc->u.hs.DeviceRemovable[1] = 0xff;
226+
BUILD_BUG_ON(VHCI_NPORTS > USB_MAXCHILDREN);
227+
width = desc->bNbrPorts / 8 + 1;
228+
desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * width;
229+
memset(&desc->u.hs.DeviceRemovable[0], 0, width);
230+
memset(&desc->u.hs.DeviceRemovable[width], 0xff, width);
226231
}
227232

228233
static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,

0 commit comments

Comments
 (0)