Skip to contentSkip to conversation

usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports

PATCH In review pip-izony 2 participants 2 messages May 18 – May 19 USB

lore
Share & tools
lore

pip-izony

author
#0 lore raw

PATCH 1/1 usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports

From: Seungjin Bae <[email protected]>

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")
---
 drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/dummy_hcd.c +4 -0
index f094491b1041..f47903461ed5 100644
@@ -2134,6 +2134,8 @@ static int dummy_hub_control(
 	case ClearHubFeature:
 		break;
 	case ClearPortFeature:
+		if (wIndex != 1)
+			goto error;
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
 			if (hcd->speed == HCD_USB3) {
@@ -2248,6 +2250,8 @@ static int dummy_hub_control(
 		retval = -EPIPE;
 		break;
 	case SetPortFeature:
+		if (wIndex != 1)
+			goto error;
 		switch (wValue) {
 		case USB_PORT_FEAT_LINK_STATE:
 			if (hcd->speed != HCD_USB3) {
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · pip-izony

From: Seungjin Bae <[email protected]>

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.

Quoted 7 lines

Fix this by extending the wIndex != 1 rejection to both cases, matching the existing behavior of GetPortStatus.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

---

Quoted 28 lines
 drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/dummy_hcd.c +4 -0
index f094491b1041..f47903461ed5 100644
@@ -2134,6 +2134,8 @@ static int dummy_hub_control(
 	case ClearHubFeature:
 		break;
 	case ClearPortFeature:
+		if (wIndex != 1)
+			goto error;
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
 			if (hcd->speed == HCD_USB3) {
@@ -2248,6 +2250,8 @@ static int dummy_hub_control(
 		retval = -EPIPE;
 		break;
 	case SetPortFeature:
+		if (wIndex != 1)
+			goto error;
 		switch (wValue) {
 		case USB_PORT_FEAT_LINK_STATE:
 			if (hcd->speed != HCD_USB3) {
Signature · 1 line
2.43.0