This is a note to let you know that I've just added the patch titled usb: dwc3: gadget: Fix null pointer exception to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: usb-dwc3-gadget-fix-null-pointer-exception.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 26288448120b28af1dfd85a6fa6b6d55a16c7f2f Mon Sep 17 00:00:00 2001 From: Albert Wang <albertccwang@xxxxxxxxxx> Date: Tue, 9 Nov 2021 17:26:42 +0800 Subject: usb: dwc3: gadget: Fix null pointer exception From: Albert Wang <albertccwang@xxxxxxxxxx> commit 26288448120b28af1dfd85a6fa6b6d55a16c7f2f upstream. In the endpoint interrupt functions dwc3_gadget_endpoint_transfer_in_progress() and dwc3_gadget_endpoint_trbs_complete() will dereference the endpoint descriptor. But it could be cleared in __dwc3_gadget_ep_disable() when accessory disconnected. So we need to check whether it is null or not before dereferencing it. Fixes: f09ddcfcb8c5 ("usb: dwc3: gadget: Prevent EP queuing while stopping transfers") Cc: stable <stable@xxxxxxxxxxxxxxx> Reviewed-by: Jack Pham <quic_jackp@xxxxxxxxxxx> Signed-off-by: Albert Wang <albertccwang@xxxxxxxxxx> Link: https://lore.kernel.org/r/20211109092642.3507692-1-albertccwang@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/usb/dwc3/gadget.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2918,6 +2918,9 @@ static bool dwc3_gadget_endpoint_trbs_co struct dwc3 *dwc = dep->dwc; bool no_started_trb = true; + if (!dep->endpoint.desc) + return no_started_trb; + dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) @@ -2965,6 +2968,9 @@ static void dwc3_gadget_endpoint_transfe { int status = 0; + if (!dep->endpoint.desc) + return; + if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) dwc3_gadget_endpoint_frame_from_event(dep, event); Patches currently in stable-queue which might be from albertccwang@xxxxxxxxxx are queue-5.10/usb-dwc3-gadget-fix-null-pointer-exception.patch