Shahina Shaik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/68903 )
Change subject: intel/common/basecode/debug: Fix potential NULL pointer dereference ......................................................................
intel/common/basecode/debug: Fix potential NULL pointer dereference
Found-by: Klockwork BUG=NONE TEST=Boot to OS on Nivviks
Change-Id: I154011963e945b54dfca07f884e473d44dc4e813 Signed-off-by: Shaik Shahina shahina.shaik@intel.com --- M src/soc/intel/common/basecode/debug/debug_feature.c 1 file changed, 22 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/68903/1
diff --git a/src/soc/intel/common/basecode/debug/debug_feature.c b/src/soc/intel/common/basecode/debug/debug_feature.c index 4b9a7cb..ceedeab 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;