Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1992302imm; Thu, 24 May 2018 04:09:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoRdOO5go9nCpRLEJKgxU8+YAH1Zl67v1Qw2wki9i6MGUEJbOxF6ulq5RZkWMwsrcrUzKI9 X-Received: by 2002:a62:91b:: with SMTP id e27-v6mr6808739pfd.93.1527160199124; Thu, 24 May 2018 04:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160199; cv=none; d=google.com; s=arc-20160816; b=nigHIK26kd3Lm0AawKYQZbFZoEnYOQj4LqXvoowqx4V6aQArDvXHcK6Ai9bN0GVpdH RrRIIsuCpByBEDWCSWIFHXLpTZDknXQSs6vPsh234bhwIPkuQn6cypHQzYJEulZSOQVA Z+G/T56YYQX/xZnHKqkp8lLMsWDSS91GJTQbDDQ/HOBn+VIqKs1t/v44oYe33M4jIEIV LuBxkE4Mm0636U32DLePABwUPBkJdV21CMzRzSKUnJvqApbpaA2x+WvDDsTTWD0dpLce WHjkWv/tNXYINYHecevyvuHrNZoleRhICU9TzASUK3MmTFe65f66ZZcu0InnEzbLqNnN aXfw== 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=SwagI60bBaOYS5HuRpVRYlpFHM69nctTLkP2bFY+cvY=; b=fba1yRgzCg3ryooUaqrI27mCW/sO0HcpFbfpPi/1RcVtarS0XTxDNBiB3A9bYiOEJp Eh3q7657D70QedDKC9wsyTR1clBQnLrNmcPBmzZVU3w031W3WA/A/Ys35OTudhrb6aXl 14EKADACvp/39h2V8T5boK0y1t3WV6VJx86HWn8NTVZ96krpZyyW9D3orNFhdXm7JEM4 jAsncq81c4sVomP3ns9ExnZnw/LGk3pNgzEo8ZHk5zy5p6EN2IB4dgd0hsoCYbpmlumm ceOCAt4KYOFylDr7JFd1EOewIFt6XP9zCmlKB8i5ST9u3kutpjHoHMNPCzlAnazba1pK nBoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1lXgV2Gb; 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 a33-v6si20986793pld.167.2018.05.24.04.09.34; Thu, 24 May 2018 04:09:59 -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=1lXgV2Gb; 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 S968201AbeEXJye (ORCPT + 99 others); Thu, 24 May 2018 05:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:34584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968174AbeEXJy3 (ORCPT ); Thu, 24 May 2018 05:54:29 -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 865DE20892; Thu, 24 May 2018 09:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155669; bh=JtGUWKHoZGr0Blou8+hK8g1tx5rWd2JS65l0FmJ7JSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1lXgV2Gbpf7u+ehb4zBvg6Xusl+XhLKuAkglmyfUkUzMhUu8mJzWgCfQ+07yuThZG 7POmEUFoYfvgPBCLPHgwTkgd5Q8FJzD3sVcWNNSXF1pTL4gHEotRK5hz0JceHjjhaC Ik86ikgIwtbJyk4+qOrLfy7SFNP75RGFIveGfz9Y= 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.14 072/165] xhci: zero usb device slot_id member when disabling and freeing a xhci slot Date: Thu, 24 May 2018 11:37:58 +0200 Message-Id: <20180524093624.931719410@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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: 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 @@ -926,6 +926,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; }