Return-Path: Received: from mga06.intel.com ([134.134.136.31]:57017 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759014AbdACQ1u (ORCPT ); Tue, 3 Jan 2017 11:27:50 -0500 From: Mathias Nyman To: Cc: , Lu Baolu , , Mathias Nyman Subject: [PATCH 02/11] usb: xhci: fix return value of xhci_setup_device() Date: Tue, 3 Jan 2017 18:28:44 +0200 Message-Id: <1483460933-15567-3-git-send-email-mathias.nyman@linux.intel.com> In-Reply-To: <1483460933-15567-1-git-send-email-mathias.nyman@linux.intel.com> References: <1483460933-15567-1-git-send-email-mathias.nyman@linux.intel.com> Sender: stable-owner@vger.kernel.org List-ID: From: Lu Baolu 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". Cc: # v4.3+ Signed-off-by: Lu Baolu Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1cd5641..0c8deb9 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3787,8 +3787,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, -- 1.9.1