Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2505059imm; Mon, 28 May 2018 09:20:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZprZYUIIS5PNVeEf5cp3eS/na5+4Vpm5ETV7tv0NNTNIpny3KzLnx8UJowRvxaaNs+gGMOd X-Received: by 2002:a17:902:31a4:: with SMTP id x33-v6mr14356358plb.355.1527524403692; Mon, 28 May 2018 09:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524403; cv=none; d=google.com; s=arc-20160816; b=SPe9SfjxHASw0i1azzKDc2Qhrf2QtcPAN4s5iJdsdLqXQA6omwl08swHMHrZx3clMe Q4Ar1mchGUiiROVaiXwv6YcdoIHmWAB11QEMFY0xSeiZfH6Gn6SXp0oYYgXrhgr7WnKb yBL4d+6SRkyRHoY9n8W//ozx8G4meJSUikl8S7HdJCUdJ8/AF5oo1JX5vCTIOUE5an/X Pxd/8vLXyFhAPCGSIVLFrbRVZbqpxl0sMxYdN/VAexNmVF6UCTSwF1AItfg26VfUPfFe O9OP/zbimoTIAU/TKfiiB0sSvMyVwkDHgFl79RwaloTXJI7gqSLz/fhfs4CMXBg2Hjyu Ek6A== 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=h/R2bhC4T6VgyO1PubiXo57Ih8+M+HIpQSntDVWw2T0=; b=nbURqN+ocQrwH+lQNWmORa9gY5xN88E2pcAqclLCwz5xVx8+f+iW4PBOZZR9sNRdzW /QGx69zeJlXhCvlvJd1DPO7VbrzkLyC9dlWqQaWrun8ayo4FPofgzKw2biqidivIv8yM kbNGDfyAo39992p5ackQ4s8GfO6Xn25X/NRttb3Nmwqez7JSlYcdV1RdRcTQrD32YAqr sD7x3bKSM/VHXexiDkZdNajULSIKY3RC9CRZitg65L4DkIwGlAO1fvtrQlms/OHEjXcB NjBokmHb3MHpdFkVJTUTdfaj/2qK3+I9ai+hmTerBYm2/jS/3WS+8El5bYP9c61ux6EQ bDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xoF2xX13; 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 x22-v6si1913494plr.288.2018.05.28.09.19.48; Mon, 28 May 2018 09:20: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=xoF2xX13; 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 S936728AbeE1KMU (ORCPT + 99 others); Mon, 28 May 2018 06:12:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:60304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936718AbeE1KMK (ORCPT ); Mon, 28 May 2018 06:12:10 -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 111092086D; Mon, 28 May 2018 10:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502329; bh=wnxhQrnbtO7QT0sm9jUfIOmqusC1SVsldV38c5vOMHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xoF2xX13xngRiDgalvSyNaNZe+/9ChR0oV3uJR2ms43wRq+xIyRmwK9L8u7vM5Hr0 4Z7h/8GcH+YN/F+md/vkciWzWYWSiQcb+/LudId9XeebsGfDTGV6RsBxTeB5ApyJls TCzg3BWEO7ren0sQi4ftMtb8FFrRtYZaMSvEP7TM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman , Sasha Levin Subject: [PATCH 3.18 147/185] xhci: zero usb device slot_id member when disabling and freeing a xhci slot Date: Mon, 28 May 2018 12:03:08 +0200 Message-Id: <20180528100108.667025238@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -962,6 +962,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; }