Skip to contentSkip to conversation

usb: xhci: fix return value of xhci_setup_device()

PATCH Superseded Lu Baolu 2 participants 5 messages Sep 8, 2016

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH v2 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.

---
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
maintainer
#1 lore raw
Quoted 4 lines · Lu Baolu

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

Why is this a stable kernel issue? What bug does it fix that affects users?

thanks,

greg k-h

author
#2 lore raw

Hi Greg,

Quoted 7 lines · Greg KH
Quoted 4 lines · Lu Baolu

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

Why is this a stable kernel issue? What bug does it fix that affects users?

During usb device enumeration, if xhci 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 will mislead usb core to continue enumeration:
reading device descriptor, which will result in failure, and users will get a misleading message like "device descriptor read/8, error -110".

Best regards,
Lu Baolu

maintainer
#3 lore raw
Quoted 11 lines · Lu Baolu

Hi Greg,

Quoted 7 lines · Greg KH
Quoted 4 lines · Lu Baolu

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

Why is this a stable kernel issue? What bug does it fix that affects users?

Quoted 6 lines

During usb device enumeration, if xhci 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 will mislead usb core to continue enumeration:
reading device descriptor, which will result in failure, and users will get a misleading message like "device descriptor read/8, error -110".

Why didn't you include this in the changelog text so that it is obvious why this patch is needed?

Don't just describe what the patch does, we can read C code, describe _why_ it is needed.

thanks,

greg k-h

author
#4 lore raw

Hi Greg,

Quoted 17 lines · Greg KH
Quoted 8 lines · Lu Baolu

Hi Greg,

Quoted 5 lines · Greg KH
Quoted 4 lines · Lu Baolu

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

Quoted 8 lines
Quoted 2 lines

Why is this a stable kernel issue? What bug does it fix that affects users?

During usb device enumeration, if xhci 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 will mislead usb core to continue enumeration:
reading device descriptor, which will result in failure, and users will get a misleading message like "device descriptor read/8, error -110".

Quoted 5 lines

Why didn't you include this in the changelog text so that it is obvious why this patch is needed?

Don't just describe what the patch does, we can read C code, describe _why_ it is needed.

Yes. Thank you for the guidance. I will do it in a v3 patch.

Best regards,
Lu Baolu