Skip to content

Commit 7d96335

Browse files
pip-izonygregkh
authored andcommitted
usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports
The `dummy_hub_control()` function handles USB hub class requests to the virtual root hub. The `GetPortStatus` case returns -EPIPE for requests with `wIndex != 1`, since the virtual root hub has only a single port. However, the `ClearPortFeature` and `SetPortFeature` cases lack the same check. Fix this by extending the `wIndex != 1` rejection to both cases, matching the existing behavior of `GetPortStatus`. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable <stable@kernel.org> Suggested-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Seungjin Bae <eeodqql09@gmail.com> Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260518234314.1889396-1-eeodqql09@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f1ecb0e commit 7d96335

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/usb/gadget/udc/dummy_hcd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,8 @@ static int dummy_hub_control(
21342134
case ClearHubFeature:
21352135
break;
21362136
case ClearPortFeature:
2137+
if (wIndex != 1)
2138+
goto error;
21372139
switch (wValue) {
21382140
case USB_PORT_FEAT_SUSPEND:
21392141
if (hcd->speed == HCD_USB3) {
@@ -2248,6 +2250,8 @@ static int dummy_hub_control(
22482250
retval = -EPIPE;
22492251
break;
22502252
case SetPortFeature:
2253+
if (wIndex != 1)
2254+
goto error;
22512255
switch (wValue) {
22522256
case USB_PORT_FEAT_LINK_STATE:
22532257
if (hcd->speed != HCD_USB3) {

0 commit comments

Comments
 (0)