summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
authorFred Reitberger <reitbergerfred@gmail.com>2023-06-05 16:01:13 -0400
committerMartin L Roth <gaumless@gmail.com>2023-06-06 21:04:25 +0000
commit45194b19f8ed143604da684a92e2c9aaa433cce4 (patch)
treeb9544377f99cc985d332e9e262db53e74f1e0038 /payloads
parente4893d6b80806b9748a3593310278e65a3f63dee (diff)
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>
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/drivers/usb/xhci.c4
1 files changed, 4 insertions, 0 deletions
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;
}