From 2889787522eac3895611c777b959eb66272b4c08 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Fri, 24 May 2024 01:33:52 +0530 Subject: mb/google/nissa: Fix potential null pointer dereference * Introduce a null check before calling `gpio_padbased_override` in `variant_configure_pads`. * This prevents potential errors in cases where the `variant_gpio_override_table` function returns a null pointer, indicating that there are no override pads to configure. BUG=b:334826281 TEST=Able to avoid hang incase there is no GPIO override. Change-Id: I733210a08091b37eda6e6b0d6924aafd5e7e6280 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/82628 Reviewed-by: Dinesh Gehlot Reviewed-by: Kapil Porwal Reviewed-by: Eric Lai Tested-by: build bot (Jenkins) --- src/mainboard/google/brya/variants/baseboard/nissa/ramstage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mainboard/google/brya') diff --git a/src/mainboard/google/brya/variants/baseboard/nissa/ramstage.c b/src/mainboard/google/brya/variants/baseboard/nissa/ramstage.c index dc686fe242..64e1b14cfb 100644 --- a/src/mainboard/google/brya/variants/baseboard/nissa/ramstage.c +++ b/src/mainboard/google/brya/variants/baseboard/nissa/ramstage.c @@ -16,7 +16,8 @@ void variant_configure_pads(void) base_pads = variant_gpio_table(&base_num); gpio_padbased_override(padbased_table, base_pads, base_num); override_pads = variant_gpio_override_table(&override_num); - gpio_padbased_override(padbased_table, override_pads, override_num); + if (override_pads != NULL) + gpio_padbased_override(padbased_table, override_pads, override_num); fw_config_gpio_padbased_override(padbased_table); gpio_configure_pads_with_padbased(padbased_table); free(padbased_table); -- cgit v1.2.3