From eac84ca35c9b8052d198a7ab3593ae8f5bbb1aa8 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Mon, 13 Aug 2018 09:45:37 -0700 Subject: intel/common/block: Fix issues found by klockwork src/soc/intel/common/block/cpu/mp_init.c Function init_cpus: Pointer dev checked for NULL may be dereferenced. src/soc/intel/common/block/graphics/graphics.c Function graphics_get_bar: Pointer dev returned from call may be NULL and will be dereferenced. BRANCH=None TEST=Built & booted Yorp board. Change-Id: I5e7caa15a3911e05ff346d338493673af5318a51 Signed-off-by: John Zhao Reviewed-on: https://review.coreboot.org/28060 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held --- src/soc/intel/common/block/cpu/mp_init.c | 3 ++- src/soc/intel/common/block/graphics/graphics.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/soc/intel') diff --git a/src/soc/intel/common/block/cpu/mp_init.c b/src/soc/intel/common/block/cpu/mp_init.c index f52709dfce..dd5cc44845 100644 --- a/src/soc/intel/common/block/cpu/mp_init.c +++ b/src/soc/intel/common/block/cpu/mp_init.c @@ -134,7 +134,8 @@ static void init_cpus(void *unused) microcode_patch = intel_microcode_find(); intel_microcode_load_unlocked(microcode_patch); - soc_init_cpus(dev->link_list); + if (dev && dev->link_list) + soc_init_cpus(dev->link_list); } static void wrapper_x86_setup_mtrrs(void *unused) diff --git a/src/soc/intel/common/block/graphics/graphics.c b/src/soc/intel/common/block/graphics/graphics.c index c6ea7e2dca..74a5cae4bb 100644 --- a/src/soc/intel/common/block/graphics/graphics.c +++ b/src/soc/intel/common/block/graphics/graphics.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -36,9 +37,10 @@ static uintptr_t graphics_get_bar(unsigned long index) { struct device *dev = SA_DEV_IGD; struct resource *gm_res; + assert(dev != NULL); /* Check if Graphics PCI device is disabled */ - if (!dev->enabled) + if (!dev || !dev->enabled) return 0; gm_res = find_resource(dev, index); -- cgit v1.2.3