Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2551133ima; Mon, 22 Oct 2018 11:37:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV606sSWybEMvmo9j4TePly7644HZXI+zo/iKjBMjScq2FaJ4eqi7fKuHLT/biquYg3scMxIq X-Received: by 2002:a17:902:162:: with SMTP id 89-v6mr44915903plb.91.1540233473446; Mon, 22 Oct 2018 11:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540233473; cv=none; d=google.com; s=arc-20160816; b=zL4l8AeCQ171aFop5ZR/lI7IIyv8xcaucnQjly8FhWEB8KCWIoPCcBWfpci7YQ7Z4H R93kP5yurlb13Xnvj7FHnSh1ICSJZYc4DBPuJDHbhx22y3LIMDvI7Xao5vuQe+NOplJ/ 8RFemDJf9rOvsSblux5Kfc6iHBkda90KRIQpVEBlO+NTnWf7GC4V6Y0x5pRAXlC25aH9 7y4tP78CajisKNxnB5M0krWic2quStKQCGljxZOFT4iOYy5TeJQ5Z9K4x812anCm8AuG JWiV4ZjMRYK5o0oHb3ZlTqVcALT5dGBKDYFw74qQa+hgeEuJTR7mXKyel6UsTJG74n/5 GQ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from; bh=fYzErP0jFeS15N7Xh6VRMokS0JtFA1DHFMRqjkbxcp8=; b=J07Ik3AAONel8gibmndFjU9+pDj/pKbSquLyDpE9vw9xfdCkbzoSPqHDMd32r7E8TO g4MbknOTU5oYi9NXUr17fzHQbXCS2LOGy6+TEdYBSr7GGVwPoFJ3mEni0SD/0RgEBAeL x6oCWKmTuW4OL9VjSzEAUbhQ8ESX84iERPtJsQAMj7HPy21+pzL7Qvfxi6SRuzNgoaH2 UC8C5LJkaS+LkKcefZcWyAsY0v5XxWqD1fxltDmAERGvR22bNLq0aDhYvvGVbCPYGxYr UWOGg6HTKWlr+X64fewJOWjw1bryJS8C596qW1YBvHXoYueJ7DwK8pjWnqlYAeEvj4SR 5qPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20-v6si34020093pgm.192.2018.10.22.11.37.38; Mon, 22 Oct 2018 11:37:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728845AbeJWCCh (ORCPT + 99 others); Mon, 22 Oct 2018 22:02:37 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51630 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727330AbeJWCCh (ORCPT ); Mon, 22 Oct 2018 22:02:37 -0400 Received: from [111.196.56.27] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gEeEN-0006T5-3c; Mon, 22 Oct 2018 17:43:07 +0000 From: Aaron Ma To: aaron.ma@canonical.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] usb: xhci: fix uninitialized completion when USB3 port got wrong status Date: Tue, 23 Oct 2018 01:42:46 +0800 Message-Id: <1540230167-12528-1-git-send-email-aaron.ma@canonical.com> X-Mailer: git-send-email 1.8.5.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Realtek USB3.0 Card Reader [0bda:0328] reports wrong port status on Cannon lake PCH USB3.1 xHCI [8086:a36d] after resume from S3, after clear port reset it works fine. Since this device is registered on USB3 roothub at boot, when port status reports not superspeed, xhci_get_port_status will call an uninitialized completion in bus_state[0]. Kernel will hang because of NULL pointer. Restrict the USB2 resume status check in USB2 roothub to fix hang issue. Cc: stable@vger.kernel.org Signed-off-by: Aaron Ma --- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci-ring.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 7e2a531ba321..56a08daa7431 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -876,7 +876,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, status |= USB_PORT_STAT_SUSPEND; } if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME && - !DEV_SUPERSPEED_ANY(raw_port_status)) { + !DEV_SUPERSPEED_ANY(raw_port_status) && hcd->speed < HCD_USB3) { if ((raw_port_status & PORT_RESET) || !(raw_port_status & PORT_PE)) return 0xffffffff; diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index f0a99aa0ac58..7318fc422b6c 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1634,7 +1634,7 @@ static void handle_port_status(struct xhci_hcd *xhci, * RExit to a disconnect state). If so, let the the driver know it's * out of the RExit state. */ - if (!DEV_SUPERSPEED_ANY(portsc) && + if (!DEV_SUPERSPEED_ANY(portsc) && hcd->speed < HCD_USB3 && test_and_clear_bit(hcd_portnum, &bus_state->rexit_ports)) { complete(&bus_state->rexit_done[hcd_portnum]); -- 2.19.1