Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xhci: don't create endpoint debugfs entry before ring buffer is set.

Make sure xHC completes the configure endpoint command and xhci driver
sets the ring pointers correctly before we create the user readable
debugfs file.

In theory there was a small gap where a user could have read the
debugfs file and cause a NULL pointer dereference error as ring
pointer was not yet set, in practise we want this change to simplify
the upcoming streams debugfs support.

Fixes: 02b6fdc2a153 ("usb: xhci: Add debugfs interface for xHCI driver")
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200918131752.16488-10-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mathias Nyman and committed by
Greg Kroah-Hartman
167657a1 edc649a8

+1 -2
+1 -2
drivers/usb/host/xhci.c
··· 1918 1918 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 1919 1919 trace_xhci_add_endpoint(ep_ctx); 1920 1920 1921 - xhci_debugfs_create_endpoint(xhci, virt_dev, ep_index); 1922 - 1923 1921 xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n", 1924 1922 (unsigned int) ep->desc.bEndpointAddress, 1925 1923 udev->slot_id, ··· 2950 2952 xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); 2951 2953 virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; 2952 2954 virt_dev->eps[i].new_ring = NULL; 2955 + xhci_debugfs_create_endpoint(xhci, virt_dev, i); 2953 2956 } 2954 2957 command_cleanup: 2955 2958 kfree(command->completion);