Received: by 10.213.65.68 with SMTP id h4csp872471imn; Tue, 27 Mar 2018 10:19:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx486mnDkAHOAyB0i0Egycs4snYMNg0Nn2eKkBUCp+w6eA4K+KFpfqC0myXK4YrQv5XLFYqEH X-Received: by 2002:a17:902:3181:: with SMTP id x1-v6mr213166plb.2.1522171167401; Tue, 27 Mar 2018 10:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171167; cv=none; d=google.com; s=arc-20160816; b=qFbkRD138yNeykAbgfXEoMwizhQCCqgKeamSTIJh8/u/+6AdHx/8zVMw2v1zEL+ARQ GarNm4/fFFz68glbkL6b8bSQ5n6PGYwPZKH1UPDNq2JEMTRb54OrFfnKTXfRo2jml/+t hn8L1vZtzjyVvH/mchLY8QPn24T2FWmnA93zDG25JOz/ynMUw3Lr7R+9xGpzDQxPQHxj Kyn1doE6N2j4uLFCGoysldfmdCSZo7c+yZLlbSKOXdVv/qmLddXqchwRVc/jwGb9ymR9 G/U89g4M8VFu34RDVatIpaMUD++CpiM4j4NLIHB+IJwQaimMhKbmZUdZU2XRj9vrq0TI xmvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vhcnMehMDfhujCHlcHdPElIr+yHMu8m3hViMxzz8if0=; b=OwmeQ1R7+v86NUOAHfwmTrb7P/0UdtkeW7wN0yw4jVPc7JOQKqK21EbtPr6aZmGWuK nrQl5IXr4XGJTKOpmCB1pW4KqNQjoHm9+8eSUPDbIe5KgxRYFF32ilXiF/Ngvq9QDn7L YSRqym0SVwwfELFk7GffwrZcR1YRIk9+Pz3889h/IXQUvYIQKpoWZKfQB3vPNrSjEULO drQDJYeRhD002rjQjkju+k8wlo6wXoCur5Osids7ZsORbslxsnh23zkOobLR8ppe+IsX hjEnCrTHT4Wr2DrnP/eSkUgsd8lCSAjp3m4pdowY2oExIYVuJ900NRNAFgaOy7f79nhZ GK8Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si1595024pla.390.2018.03.27.10.19.13; Tue, 27 Mar 2018 10:19:27 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755212AbeC0Qi0 (ORCPT + 99 others); Tue, 27 Mar 2018 12:38:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46740 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755168AbeC0QiY (ORCPT ); Tue, 27 Mar 2018 12:38:24 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 65B1CFF7; Tue, 27 Mar 2018 16:38:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guoqing Zhang , Lu Baolu , Mathias Nyman Subject: [PATCH 4.14 096/101] usb: xhci: Disable slot even when virt-dev is null Date: Tue, 27 Mar 2018 18:28:08 +0200 Message-Id: <20180327162755.907512389@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lu Baolu commit b64149ca016c25f30b39ac5a8f37cfb9017e19bb upstream. xhci_disable_slot() is a helper for disabling a slot when a device goes away or recovers from error situations. Currently, it checks the corespoding virt-dev pointer and returns directly (w/o issuing disable slot command) if it's null. This is unnecessary and will cause problems in case where virt-dev allocation fails and xhci_disable_slot() is called to roll back the hardware state. Refer to the implementation of xhci_alloc_dev(). This patch removes lines to check virt-dev in xhci_disable_slot(). Fixes: f9e609b82479 ("usb: xhci: Add helper function xhci_disable_slot().") Cc: Guoqing Zhang Signed-off-by: Lu Baolu Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-hub.c | 3 +++ drivers/usb/host/xhci.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -634,6 +634,9 @@ static int xhci_enter_test_mode(struct x xhci_dbg(xhci, "Disable all slots\n"); spin_unlock_irqrestore(&xhci->lock, *flags); for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) { + if (!xhci->devs[i]) + continue; + retval = xhci_disable_slot(xhci, NULL, i); if (retval) xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3571,11 +3571,7 @@ int xhci_disable_slot(struct xhci_hcd *x unsigned long flags; u32 state; int ret = 0; - struct xhci_virt_device *virt_dev; - virt_dev = xhci->devs[slot_id]; - if (!virt_dev) - return -EINVAL; if (!command) command = xhci_alloc_command(xhci, false, false, GFP_KERNEL); if (!command)