From 45194b19f8ed143604da684a92e2c9aaa433cce4 Mon Sep 17 00:00:00 2001 From: Fred Reitberger Date: Mon, 5 Jun 2023 16:01:13 -0400 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75645 Reviewed-by: Jon Murphy Reviewed-by: Karthik Ramasubramanian Reviewed-by: Martin L Roth Tested-by: build bot (Jenkins) --- payloads/libpayload/drivers/usb/xhci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c index 6737a140ec..e9a7ead18b 100644 --- a/payloads/libpayload/drivers/usb/xhci.c +++ b/payloads/libpayload/drivers/usb/xhci.c @@ -155,6 +155,9 @@ xhci_init(unsigned long physical_bar) { int i; + if (!physical_bar) + goto _exit_xhci; + /* First, allocate and initialize static controller structures */ hci_t *const controller = new_controller(); @@ -301,6 +304,7 @@ _free_xhci: /* _free_controller: */ detach_controller(controller); free(controller); +_exit_xhci: return NULL; }