Skip to contentSkip to conversation

usb: xhci: fix return value of xhci_setup_device()

PATCH New Lu Baolu 1 participant 1 message Sep 9, 2016

Subsystems (3)
lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH v3 1/1 usb: xhci: fix return value of xhci_setup_device()

xhci_setup_device() should return failure with correct error number when xhci host has died, removed or halted.

During usb device enumeration, if usb host is not accessible (died, removed or halted), the hc_driver->address_device() should return a corresponding error code to usb core. But current xhci driver just returns success. This misleads usb core to continue the enumeration by reading the device descriptor, which will result in failure, and users will get a misleading message like "device descriptor read/8, error -110".

---
v2->v3:
- improve the commit description
v1->v2:
- fix email mismatch issue

 drivers/usb/host/xhci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +3 -1
index 01d96c9..3e66e73 100644
@@ -3785,8 +3785,10 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
 
 	mutex_lock(&xhci->mutex);
 
-	if (xhci->xhc_state)	/* dying, removing or halted */
+	if (xhci->xhc_state) {	/* dying, removing or halted */
+		ret = -ESHUTDOWN;
 		goto out;
+	}
 
 	if (!udev->slot_id) {
 		xhci_dbg_trace(xhci, trace_xhci_dbg_address,
Signature · 1 line
2.1.4