Skip to contentSkip to conversation

patch "xhci: Fix NULL pointer dereference in xhci_clear_tt_buffer_complete()" added to usb-linus

PATCH [email protected] 1 participant 1 message Oct 4, 2019

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

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 <[email protected]>
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.

---
 drivers/usb/host/xhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/host/xhci.c +8 -0
index 00f3804f7aa7..517ec3206f6e 100644
@@ -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);
 
Signature · 1 line
2.23.0