USB: usbip: fix stub_dev hub disconnect

[ Upstream commit 9747576348 ]

If a hub is disconnected that has device(s) that's attached to the usbip layer
the disconnect function might fail because it tries to release the port
on an already disconnected hub.

Fixes: 6080cd0e92 ("staging: usbip: claim ports used by shared devices")
Signed-off-by: Jonas Blixt <jonas.blixt@actia.se>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230615092810.1215490-1-jonas.blixt@actia.se
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jonas Blixt 2023-06-15 11:28:10 +02:00 committed by Greg Kroah-Hartman
parent dae6fd9747
commit 2ed67a40dd
1 changed files with 7 additions and 2 deletions

View File

@ -462,8 +462,13 @@ static void stub_disconnect(struct usb_device *udev)
/* release port */
rc = usb_hub_release_port(udev->parent, udev->portnum,
(struct usb_dev_state *) udev);
if (rc) {
dev_dbg(&udev->dev, "unable to release port\n");
/*
* NOTE: If a HUB disconnect triggered disconnect of the down stream
* device usb_hub_release_port will return -ENODEV so we can safely ignore
* that error here.
*/
if (rc && (rc != -ENODEV)) {
dev_dbg(&udev->dev, "unable to release port (%i)\n", rc);
return;
}