Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2181406imm; Mon, 28 May 2018 03:24:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpauA0YBrScSQLqehAUigj4fV8zijMksliwS3YOAvnfPJZmPc4IVGeTOT+8sJVxXS3dH5RL X-Received: by 2002:a65:4309:: with SMTP id j9-v6mr9985591pgq.375.1527503042961; Mon, 28 May 2018 03:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527503042; cv=none; d=google.com; s=arc-20160816; b=d/V/AFP19ROZ786q5hRX4QntcRVKI9+6aRS/K3KHOGuN3qyhyz0ODsOMI+uuxFTno7 zXxmuoewTBMI2edJ50M3AJINnlwQLLUHJSp9Z9ffyyJCoBYj+XVuFSXxAg/cDZTzA5UJ MiJX9ioapDSyatdsWusMjtgafT+UCHpk357RY5FJAT2q40ISQNKmJl3uBCOF3kPO6vXW edZHKU8eiT85/ehemaREHa5MrM3dR8EmTignKY9C5QtBOR5ZgNeXKz2b5LaTQzRB1KaM 9yGLd2/9fR1BPAJtMWiLx/2nENGgE6APnBDZmmTX8M2BcxSNYbfBnSQOxiDQhsEbaV84 9BHg== 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:dkim-signature :arc-authentication-results; bh=W4LEQeBQtkZbkdyz9S66OOpEPlTWS6I4IY+VO35pji4=; b=aU8vM3aYb/ybfPQnnVZVxKQhOrKEhfWavZHZwwIgyWr5F2Z3nqidD7WXXfRP4PeR8D bZ3HIoomjLBRVmeqVdSaizDIqtOscxhM0OU/ZckKTQcLmZvy7rp7kyqaVUcBnZd5XVFE wGH4PvWlMp6SiNfVWQ21tBmKPbdH9SZP/Zpc+wRCYns9mBEhXhwyQP+wgdjsvBOPPrFW 1lidYdi2I7JsL1lboP2W+oC6rrtFVII2fcn/dVTWC+v/n8YcqSDG5MJBK2847qSxixUj HORSFFPhIoo2POQoOidVv0VNvAv3n8REW0UM4kIEWwIeP/HhX9x+xfjfyTzZj91ZBPuQ /rxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pg2HHREr; 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 d63-v6si10970672pgc.591.2018.05.28.03.23.47; Mon, 28 May 2018 03:24:02 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Pg2HHREr; 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 S1033499AbeE1KXd (ORCPT + 99 others); Mon, 28 May 2018 06:23:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:42812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032835AbeE1KX1 (ORCPT ); Mon, 28 May 2018 06:23:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7EDD520843; Mon, 28 May 2018 10:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527503007; bh=KT1oeBl4+v8K6kQrmYIYtyoauUkqVQdzdGcuseNsfvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pg2HHRErsZHVfuB+4KDzhsG/umgv794WRDdJMlj9Th2RJtu1dpUEbXyWPYK/w7BMg oWhc1bso1SIOTsh5A0/RVFL23/XY7cd1tcLBa1559KmaJDdwhHANqnwY79XMA+MSzN 1W5fg2MUa52eKn2woOwHx/PT50/+ZXmQ0G1BvkDI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman , Sasha Levin Subject: [PATCH 4.4 209/268] xhci: zero usb device slot_id member when disabling and freeing a xhci slot Date: Mon, 28 May 2018 12:03:03 +0200 Message-Id: <20180528100225.917433568@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mathias Nyman [ Upstream commit a400efe455f7b61ac9a801ac8d0d01f8c8d82dd5 ] set udev->slot_id to zero when disabling and freeing the xhci slot. Prevents usb core from calling xhci with a stale slot id. xHC controller may be reset during resume to recover from some error. All slots are unusable as they are disabled and freed. xhci driver starts slot enumeration again from 1 in the order they are enabled. In the worst case a stale udev->slot_id for one device matches a newly enabled slot_id for a different device, causing us to perform a action on the wrong device. Signed-off-by: Mathias Nyman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-mem.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -960,6 +960,8 @@ void xhci_free_virt_device(struct xhci_h if (dev->out_ctx) xhci_free_container_ctx(xhci, dev->out_ctx); + if (dev->udev && dev->udev->slot_id) + dev->udev->slot_id = 0; kfree(xhci->devs[slot_id]); xhci->devs[slot_id] = NULL; }