Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1948777imm; Thu, 24 May 2018 03:27:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrOZmwyXiSi5av5R+k+c7865ca6dT4mC5uI94q95oGp3F2Fcn0BaQs9Sq7GROVijzEha99Z X-Received: by 2002:a62:9515:: with SMTP id p21-v6mr6653869pfd.62.1527157623859; Thu, 24 May 2018 03:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157623; cv=none; d=google.com; s=arc-20160816; b=yDrn4Hevu2XCTbbqcTIN0KnyqI8rMkj4Z/eRqkECL4bKN0BfBKM2Gp9USodVWj9N+Y LsMslYmGQ2bJQKdZ6JhKswgiidcSvliL+SUo2AujRhHyhBXxvMT/JgeWYoKg2vN2pFjB zuJr8q+8u80mu5W4HYmQ3iWdGuwMGOk6uXTqXUK8qh2Ii/+PtgNTwXvFuzaeQXkU4Yu8 jqxUMJKWBtDcyGZt/2sHf9pOC6L2rOpJUDbkuW/OaKONbK30evqTmkNs4JowehHPvOVz 4aJ9tw1KyVTplXh+ivBFwpYCIqN5OwyuXHnR4+88pZAQb3TJjKYnIHDMWw2NQpy+PdNs CbTA== 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=p1aFHun3s7+lA6VY3vlFjU19bWt+JlFMX89cB3Mi3nM=; b=GU+suEc7KuDplblOvUGaqYusxSRr6CuIkkPeHfnP1f87qEW9Ao7pvUaDJatNL04O6O fi2hon+5Yych2bCLOi/EOEFc0h93dyLcwO5qxRczbPDvXFEZ8Tc+AEJ4juNETangP/QM cWS6LKUinRCzZg4TLXS1sOzyVoxw1pBQGmu0PnT2dedEToK5pOjTShp0/SIE5jzqfxMW al0gLMTQBeW4cIKxO5wE6+fYjUusmQn01fgdM9XsY+cdGdsCBgDzOADrjsoFtyOAH5zh BDyZoN2JtHrY/9VgZ4XgCU9ocQc+DB65LcQyB53A20LLV7vGnUPHD6eCeMU8ciCeYA6u hjxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V4uoO+yt; 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 q6-v6si20325953pfh.17.2018.05.24.03.26.49; Thu, 24 May 2018 03:27:03 -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=V4uoO+yt; 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 S1032043AbeEXK0J (ORCPT + 99 others); Thu, 24 May 2018 06:26:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:48236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031028AbeEXKB7 (ORCPT ); Thu, 24 May 2018 06:01:59 -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 B82E920891; Thu, 24 May 2018 10:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156119; bh=kapdzHwNH7N416Yumnl/s+vX9xPeRXptpm12KejjenA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V4uoO+ytTuSzoSItOBJPjPEiEIM+jc9YqvFd91tJJtEkMqk6B0UI8U9s5zmSqYj2w 8prchjdlS3pWvFDeEYLEmnddaLBR6CaR3emDfqPwReKfmhZV0PJW/1rtoRKVtBmSq5 hPpcrjsqzidQKlH3kW5BB8SEP168P244l4PzCt/0= 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.16 071/161] xhci: zero usb device slot_id member when disabling and freeing a xhci slot Date: Thu, 24 May 2018 11:38:16 +0200 Message-Id: <20180524093027.003996417@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@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.16-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: Greg Kroah-Hartman 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 @@ -913,6 +913,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; }