mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-03 18:20:25 +02:00 
			
		
		
		
	usb: dwc3: gadget: Fix null pointer exception
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: f09ddcfcb8 ("usb: dwc3: gadget: Prevent EP queuing while stopping transfers")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Jack Pham <quic_jackp@quicinc.com>
Signed-off-by: Albert Wang <albertccwang@google.com>
Link: https://lore.kernel.org/r/20211109092642.3507692-1-albertccwang@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
			
			
This commit is contained in:
		
							parent
							
								
									3b8599a6f4
								
							
						
					
					
						commit
						2628844812
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
					@ -3263,6 +3263,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
 | 
				
			||||||
	struct dwc3		*dwc = dep->dwc;
 | 
						struct dwc3		*dwc = dep->dwc;
 | 
				
			||||||
	bool			no_started_trb = true;
 | 
						bool			no_started_trb = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!dep->endpoint.desc)
 | 
				
			||||||
 | 
							return no_started_trb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
 | 
						dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
 | 
						if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
 | 
				
			||||||
| 
						 | 
					@ -3310,6 +3313,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int status = 0;
 | 
						int status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!dep->endpoint.desc)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
 | 
						if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
 | 
				
			||||||
		dwc3_gadget_endpoint_frame_from_event(dep, event);
 | 
							dwc3_gadget_endpoint_frame_from_event(dep, event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue