From 14dad2670e4101be990a0e3ac5fe15ca30ca06b3 Mon Sep 17 00:00:00 2001 From: Shaik Shahina Date: Thu, 27 Oct 2022 18:18:20 +0530 Subject: soc/intel/common: Fix potential NULL pointer dereference BUG=NONE TEST=Boot to OS on Nivviks Change-Id: I154011963e945b54dfca07f884e473d44dc4e813 Signed-off-by: Shaik Shahina Reviewed-on: https://review.coreboot.org/c/coreboot/+/68903 Reviewed-by: Rizwan Qureshi Tested-by: build bot (Jenkins) Reviewed-by: Sridhar Siricilla Reviewed-by: Eric Lai --- src/soc/intel/common/basecode/debug/debug_feature.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/soc/intel/common/basecode/debug/debug_feature.c b/src/soc/intel/common/basecode/debug/debug_feature.c index 4b9a7cbf2e..64919346f8 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 @@ bool is_debug_cse_fw_update_disable(void) 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; -- cgit v1.2.3