Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2025412imm; Thu, 24 May 2018 04:43:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrGBtljxM7PHYWLcgsUbB4dAEOXVHD3K7cj7nEsN8x5V9f26yDLzhQIdwbGn+fvxHmdm3+q X-Received: by 2002:a63:61d6:: with SMTP id v205-v6mr3867081pgb.432.1527162223980; Thu, 24 May 2018 04:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162223; cv=none; d=google.com; s=arc-20160816; b=c2jwhDrRYZLEIzn3Nzy+z8zmL51ql1lPFmLUHdDScU/NQXJMFm18GHU+Rh/tpgP4mq r7+/qz1Gd2Vl1hZOJ8TEqHbOKdAh75Q+uOtkIZHQYlyP5QUaZB03xLeIHc786SGER6z0 jMqkoOTUVw1KY60QyCmvkUWC9z9hdqKWBdNaIcwue+8IIQ/is2eW69qTMOngMrEIUQTn w094NRGvYX0y7SWQUqmwsAxMZmiludHMrwZR47MKUSXpXsyXycM8bhraFp3Ev2we6cGW DqW9HBRB8Cq5FYjhJS1s6HQomgmfTy8Gv+LViN+oTifi69MuluTY0mx7Hud+BImfmFVd b3Jg== 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=jeqQzYSGerE9y5aowuzk4fY7v1RjZ7/cN8ZczHj8Hbw=; b=0+lXL+rcSFXDVsCj/+J6/z0ipxDXa4IsWLMjwcmflNRW7QOVIx6/sjZeILVNWHpqig gc38QxI0+OrWYdoeYcH7unYQZPKXqU2Ggxd9QSEZfD/wg302jQd1dpcsjIw2J/n6rKL6 lUyM0mRq1Y8ysBpoMEKlNqsQEqjCnFtPC2PF0uWeCj+ge5tRtNXUGf1r62q5L4Xt9oRg 0SN+ypBFBHxln911lgVfwvjOgrXh2KNDjROSSulzXYyYZJ5qtmeKYlNbHKcmBOGo7tNQ 94vLFoGq5fIVnd1NsWkNHm37vFoZW65TErukMqdD2HhzJKP3+5iezBYGhfMQRhWDYf0L D6eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n472K/Ef; 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 f2-v6si16990341pgq.444.2018.05.24.04.43.29; Thu, 24 May 2018 04:43:43 -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=n472K/Ef; 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 S969215AbeEXLml (ORCPT + 99 others); Thu, 24 May 2018 07:42:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:33624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966909AbeEXJsY (ORCPT ); Thu, 24 May 2018 05:48:24 -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 700FB20894; Thu, 24 May 2018 09:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155304; bh=r3yIz2sum8Vm9WuROJBlOkUiXLDtWyvXiMmHTxFlD6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n472K/Efag8nK0kfdR6fo6l+i9IWYfGR8VWqX8slx+sWDBnALX0+JgRsrQlp47mO1 ppVxpPLnzZ/x/PuAxMAElGiPrwO19eIIlhtFefajOIHARLitRksfjC4UkjOOlZ+YW9 Wi8cqYRSRQB++4z/rQs3+ZuFcAcIbfctjBel95tQ= 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.9 38/96] xhci: zero usb device slot_id member when disabling and freeing a xhci slot Date: Thu, 24 May 2018 11:38:21 +0200 Message-Id: <20180524093607.745292597@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 @@ -975,6 +975,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; }