Re: [PATCH v3 2/2] usb: host: max3421: Reject hub port requests for non-existent ports

From: Alan Stern

Date: Mon May 18 2026 - 18:00:20 EST


On Sun, May 17, 2026 at 03:03:08PM -0400, pip-izony wrote:
> From: Seungjin Bae <eeodqql09@xxxxxxxxx>
>
> The `max3421_hub_control()` function handles USB hub class requests
> to the virtual root hub. The `GetPortStatus` case correctly rejects
> requests with `index != 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 `index != 1` rejection to both cases,
> matching the existing behavior of `GetPortStatus`.
>
> Fixes: 2d53139f3162 ("Add support for using a MAX3421E chip as a host driver.")
> Suggested-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Seungjin Bae <eeodqql09@xxxxxxxxx>
> ---

Reviewed-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

Heh, this made me go back and look at dummy-hcd.c. It's missing the
same check in the same places!

Would you like to submit a patch to fix that driver as well? If not,
I'll take care of it.

Alan Stern

> v3: New patch in v3, suggested by Alan Stern.
>
> drivers/usb/host/max3421-hcd.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
> index 3d6b351dcb1a..73e76d0e6973 100644
> --- a/drivers/usb/host/max3421-hcd.c
> +++ b/drivers/usb/host/max3421-hcd.c
> @@ -1685,6 +1685,8 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index,
> case ClearHubFeature:
> break;
> case ClearPortFeature:
> + if (index != 1)
> + goto error;
> switch (value) {
> case USB_PORT_FEAT_SUSPEND:
> break;
> @@ -1728,6 +1730,8 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index,
> break;
>
> case SetPortFeature:
> + if (index != 1)
> + goto error;
> switch (value) {
> case USB_PORT_FEAT_LINK_STATE:
> case USB_PORT_FEAT_U1_TIMEOUT:
> --
> 2.43.0
>