From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 534E3FA3728 for ; Wed, 16 Oct 2019 22:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FA0C21928 for ; Wed, 16 Oct 2019 22:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263641; bh=hFaSuMMtLqZ7dMbrUvxByma5TWhJWl68+RXBc3wEyL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OB2Sd7ZrZzYnSmz8GBii0vW50XtyqlnU3hzrzYdl9X5CUujB3weCfk5jl8HSb6hZc YfanTXQqyqe6w8r1m3630QOytQRO1cvmtSupZqGqAPk6u5D+WsuVp2oa7w/f2OiF/N NMbFs6B2irLiPW+5lXPHYRYf68q7CEzvIRgOfLv8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407043AbfJPWHU (ORCPT ); Wed, 16 Oct 2019 18:07:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:51606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406690AbfJPV6O (ORCPT ); Wed, 16 Oct 2019 17:58:14 -0400 Received: from localhost (unknown [192.55.54.58]) (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 B2C0921928; Wed, 16 Oct 2019 21:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263092; bh=hFaSuMMtLqZ7dMbrUvxByma5TWhJWl68+RXBc3wEyL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WTbyRA6io6leGUumT9tq0W/wBhJuxk7dGESlN44DrX51Z8ggrqXVCNwE0Gc0pBJoC kVkz6MLMCb1OsRZ5QCga5Jo0a1Xyz52Gp89oJY0Pn6kWKmvdijceF75beYPREusx9V R+MVLPlYj2Rlt0VMn1bF7pwtsxv4PI9ODVYV5cVs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Mathias Nyman Subject: [PATCH 5.3 014/112] xhci: Fix NULL pointer dereference in xhci_clear_tt_buffer_complete() Date: Wed, 16 Oct 2019 14:50:06 -0700 Message-Id: <20191016214847.698593207@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman commit cfbb8a84c2d2ef49bccacb511002bca4f6053555 upstream. udev stored in ep->hcpriv might be NULL if tt buffer is cleared due to a halted control endpoint during device enumeration xhci_clear_tt_buffer_complete is called by hub_tt_work() once it's scheduled, and by then usb core might have freed and allocated a new udev for the next enumeration attempt. Fixes: ef513be0a905 ("usb: xhci: Add Clear_TT_Buffer") Cc: # v5.3 Reported-by: Johan Hovold Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/1570190373-30684-9-git-send-email-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5237,8 +5237,16 @@ static void xhci_clear_tt_buffer_complet unsigned int ep_index; unsigned long flags; + /* + * udev might be NULL if tt buffer is cleared during a failed device + * enumeration due to a halted control endpoint. Usb core might + * have allocated a new udev for the next enumeration attempt. + */ + xhci = hcd_to_xhci(hcd); udev = (struct usb_device *)ep->hcpriv; + if (!udev) + return; slot_id = udev->slot_id; ep_index = xhci_get_endpoint_index(&ep->desc);