summaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block/gpio
diff options
context:
space:
mode:
authorMaulik V Vaghela <maulik.v.vaghela@intel.com>2022-05-31 20:24:42 +0530
committerPaul Fagerburg <pfagerburg@chromium.org>2022-06-03 15:27:16 +0000
commitcdc1de7e9237cc3628d2262ee852b5b4b56c56ef (patch)
tree226f2999593c5e508a72fcd1c8e232643282c9cc /src/soc/intel/common/block/gpio
parent295a7508b8cd66b2934ed9b5ca253f683775150f (diff)
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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/64857 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Diffstat (limited to 'src/soc/intel/common/block/gpio')
-rw-r--r--src/soc/intel/common/block/gpio/gpio.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c
index d12281f74d..baf0e168b8 100644
--- a/src/soc/intel/common/block/gpio/gpio.c
+++ b/src/soc/intel/common/block/gpio/gpio.c
@@ -331,11 +331,23 @@ static const int mask[4] = {
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);