From b92ad0b0775b939240980bb4a1c60521efb7d008 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 5 Sep 2017 18:44:15 +0530 Subject: soc/intel/{cannonlake,skylake}: Fix null pointer dereference in klocwork MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes klocwork bug due to recent memmap.c implementation where “Pointer 'dev' returned from call to function 'dev_find_slot' at line 144 may be NULL.” Change-Id: I4c74ca410d1a0ba48634ec9928a0d9d1cc20e27a Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/21404 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Paul Menzel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Furquan Shaikh --- src/soc/intel/cannonlake/memmap.c | 2 ++ src/soc/intel/skylake/memmap.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/soc') diff --git a/src/soc/intel/cannonlake/memmap.c b/src/soc/intel/cannonlake/memmap.c index 8f842c0c5c..29f25f2693 100644 --- a/src/soc/intel/cannonlake/memmap.c +++ b/src/soc/intel/cannonlake/memmap.c @@ -91,6 +91,8 @@ static uintptr_t calculate_dram_base(void) size_t imr_size; dev = dev_find_slot(0, PCI_DEVFN(SA_DEV_SLOT_IGD, 0)); + if (!dev) + die("ERROR - device not found!"); /* Read TOLUD from Host Bridge offset */ dram_base = sa_get_tolud_base(); diff --git a/src/soc/intel/skylake/memmap.c b/src/soc/intel/skylake/memmap.c index 229afa7b43..6c640732cc 100644 --- a/src/soc/intel/skylake/memmap.c +++ b/src/soc/intel/skylake/memmap.c @@ -142,6 +142,8 @@ static u32 calculate_dram_base(void) size_t prmrr_size; dev = dev_find_slot(0, PCI_DEVFN(SA_DEV_SLOT_IGD, 0)); + if (!dev) + die("ERROR - device not found!"); /* Read TOLUD from Host Bridge offset */ dram_base = sa_get_tolud_base(); @@ -160,7 +162,6 @@ static u32 calculate_dram_base(void) if (IS_ENABLED(CONFIG_SA_ENABLE_DPR)) dram_base -= sa_get_dpr_size(); - dev = dev_find_slot(0, PCI_DEVFN(SA_DEV_SLOT_ROOT, 0)); config = dev->chip_info; if (IS_ENABLED(CONFIG_PLATFORM_USES_FSP1_1)) prmrr_size = 1*MiB; -- cgit v1.2.3