libpayload/drivers/usb/xhci.c: Check for NULL in xhci_init
Ensure the physical_bar parameter passed to xhci_init is not NULL, else return NULL. This may occur when an XHCI controller is disabled and no resources are allocated for it. BUG=b:284213001 Change-Id: I05c32612606793adcba3f4a5724092387a215d41 Signed-off-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/75645 Reviewed-by: Jon Murphy <jpmurphy@google.com> Reviewed-by: Karthik Ramasubramanian <kramasub@google.com> Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
		
				
					committed by
					
						
						Martin L Roth
					
				
			
			
				
	
			
			
			
						parent
						
							e4893d6b80
						
					
				
				
					commit
					45194b19f8
				
			@@ -155,6 +155,9 @@ xhci_init(unsigned long physical_bar)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!physical_bar)
 | 
				
			||||||
 | 
							goto _exit_xhci;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* First, allocate and initialize static controller structures */
 | 
						/* First, allocate and initialize static controller structures */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hci_t *const controller = new_controller();
 | 
						hci_t *const controller = new_controller();
 | 
				
			||||||
@@ -301,6 +304,7 @@ _free_xhci:
 | 
				
			|||||||
/* _free_controller: */
 | 
					/* _free_controller: */
 | 
				
			||||||
	detach_controller(controller);
 | 
						detach_controller(controller);
 | 
				
			||||||
	free(controller);
 | 
						free(controller);
 | 
				
			||||||
 | 
					_exit_xhci:
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user