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=-11.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 D00FFC47404 for ; Fri, 4 Oct 2019 12:33:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AA73222C0 for ; Fri, 4 Oct 2019 12:33:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570192407; bh=AyqByWesnvCOxyKKIdfFGVTt/0GwJsodBLb94CbC/lE=; h=Subject:To:From:Date:List-ID:From; b=NgkZUTCpFiW9CUN2d7TqihH7hWMc2ZUAYJ+eepPRDqnb3UBiYpTLg5WeoYj5CyAK+ tvk60NE+OZa1mj0X9ga09+I2q2XTEoaHB4UFOFv+z1VydTk7jEIiOqO/3l5hYOFsfu wqu1kqUDnz+stFzU48J1Sy5o2eR7TUT5KdZa3rSM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730695AbfJDMd1 (ORCPT ); Fri, 4 Oct 2019 08:33:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:53532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726024AbfJDMd1 (ORCPT ); Fri, 4 Oct 2019 08:33:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 1B31821D81; Fri, 4 Oct 2019 12:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570192406; bh=AyqByWesnvCOxyKKIdfFGVTt/0GwJsodBLb94CbC/lE=; h=Subject:To:From:Date:From; b=ury/4p668xZAvcCL/LGjeMAYZ34kCDf0Tt3nkWUfRIRhkhDAGE3HGVnzorYnvzXRc ukrUAhGxSh/08UUzQF+oRMbCPBGD0Ip1qPqeQpEKNyxH4PCco/FqsV2N5dWGnk6q/v QJXJ0HKAHVkIAkDT+Bu9XoO3B4jdpIxWG+XtjK+E= Subject: patch "xhci: Fix NULL pointer dereference in xhci_clear_tt_buffer_complete()" added to usb-linus To: mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org, johan@kernel.org, stable@vger.kernel.org From: Date: Fri, 04 Oct 2019 14:33:08 +0200 Message-ID: <157019238837243@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled xhci: Fix NULL pointer dereference in xhci_clear_tt_buffer_complete() to my usb git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git in the usb-linus branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will hopefully also be merged in Linus's tree for the next -rc kernel release. If you have any questions about this process, please let me know. >From cfbb8a84c2d2ef49bccacb511002bca4f6053555 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Fri, 4 Oct 2019 14:59:33 +0300 Subject: xhci: Fix NULL pointer dereference in xhci_clear_tt_buffer_complete() 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(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 00f3804f7aa7..517ec3206f6e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5238,8 +5238,16 @@ static void xhci_clear_tt_buffer_complete(struct usb_hcd *hcd, 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); -- 2.23.0