Martin L Roth has submitted this change. ( https://review.coreboot.org/c/coreboot/+/68903 )
Change subject: soc/intel/common: Fix potential NULL pointer dereference ......................................................................
soc/intel/common: Fix potential NULL pointer dereference
BUG=NONE TEST=Boot to OS on Nivviks
Change-Id: I154011963e945b54dfca07f884e473d44dc4e813 Signed-off-by: Shaik Shahina shahina.shaik@intel.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/68903 Reviewed-by: Rizwan Qureshi rizwan.qureshi@intel.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Sridhar Siricilla sridhar.siricilla@intel.com Reviewed-by: Eric Lai eric_lai@quanta.corp-partner.google.com --- M src/soc/intel/common/basecode/debug/debug_feature.c 1 file changed, 26 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Rizwan Qureshi: Looks good to me, approved Sridhar Siricilla: Looks good to me, approved Eric Lai: Looks good to me, approved
diff --git a/src/soc/intel/common/basecode/debug/debug_feature.c b/src/soc/intel/common/basecode/debug/debug_feature.c index 4b9a7cb..6491934 100644 --- a/src/soc/intel/common/basecode/debug/debug_feature.c +++ b/src/soc/intel/common/basecode/debug/debug_feature.c @@ -30,7 +30,14 @@
enum cb_err dbg_feature_cntrl_init(void) { - if (spi_flash_read(boot_device_spi_flash(), DEBUG_FEATURE_CTRL_OFFSET, + const struct spi_flash *spi_flash_dev = boot_device_spi_flash(); + + if (spi_flash_dev == NULL) { + printk(BIOS_ERR, "Failed to Initialize boot device SPI flash\n"); + return CB_ERR; + } + + if (spi_flash_read(spi_flash_dev, DEBUG_FEATURE_CTRL_OFFSET, DEBUG_FEATURE_CTRL_SZ, &dbg_feature_cntrl)) { printk(BIOS_ERR, "Failed to read Descriptor Region from SPI Flash\n"); return CB_ERR;