Maulik V Vaghela has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/64857 )
Change subject: intelblocks/gpio.c: Handle NULL return values from child functions ......................................................................
intelblocks/gpio.c: Handle NULL return values from child functions
gpio_configure_pad function gets called for most of the GPIO configuration for all the boards. This function is not handling NULL pointers properly which can cause exception in CPU.
This patch fixes the handling and function is able to return early in case the NULL pointer is passed or any subsequent child function calls return NULL.
BUG=None BRANCH=None TEST=Compilation works fine for all Alder Lake boards.
Change-Id: I97fad72cdd92f70c7c5e6fdd23fbecf535a6e388 Signed-off-by: Maulik V Vaghela maulik.v.vaghela@intel.com --- M src/soc/intel/common/block/gpio/gpio.c 1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/57/64857/1
diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c index d12281f..baf0e16 100644 --- a/src/soc/intel/common/block/gpio/gpio.c +++ b/src/soc/intel/common/block/gpio/gpio.c @@ -331,11 +331,23 @@
static void gpio_configure_pad(const struct pad_config *cfg) { - const struct pad_community *comm = gpio_get_community(cfg->pad); + const struct pad_community *comm; uint16_t config_offset; uint32_t pad_conf, soc_pad_conf; int i, pin, group;
+ if (!cfg) { + printk(BIOS_ERR, "%s: cfg value is NULL\n", __func__); + return; + } + + comm = gpio_get_community(cfg->pad); + if (!comm) { + printk(BIOS_ERR, "%s: Could not find community for pad: 0x%x\n", + __func__, cfg->pad); + return; + } + config_offset = pad_config_offset(comm, cfg->pad); pin = relative_pad_in_comm(comm, cfg->pad); group = gpio_group_index(comm, pin);