Skip to content

Commit b810896

Browse files
griffinkhgregkh
authored andcommitted
usb: core: Strengthen error handling in hub_hub_status()
commit a294967 upstream. Add additional error handling after the call to get_hub_status() in hub_hub_status(). get_hub_status() uses usb_control_msg() which does not verify that the message is the correct length, substituting it for usb_control_msg_recv() would also solve this issue but increase memory allocations. Instead, error handling is copied from the method used in hub_ext_port_status(), which shares the same flow of logic as hub_hub_status(). Assisted-by: gkh_clanker_t1000 Signed-off-by: Griffin Kroah-Hartman <griffin@kroah.com> Link: https://patch.msgid.link/20260722-usb_core_patches_2-v3-1-87622252bfdd@kroah.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf22885 commit b810896

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/usb/core/hub.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,12 @@ static int hub_hub_status(struct usb_hub *hub,
997997

998998
mutex_lock(&hub->status_mutex);
999999
ret = get_hub_status(hub->hdev, &hub->status->hub);
1000-
if (ret < 0) {
1000+
if (ret < (int)sizeof(hub->status->hub)) {
10011001
if (ret != -ENODEV)
10021002
dev_err(hub->intfdev,
10031003
"%s failed (err = %d)\n", __func__, ret);
1004+
if (ret >= 0)
1005+
ret = -EIO;
10041006
} else {
10051007
*status = le16_to_cpu(hub->status->hub.wHubStatus);
10061008
*change = le16_to_cpu(hub->status->hub.wHubChange);

0 commit comments

Comments
 (0)