From 6dc148a42b9ae719521caff43556d60cf8ef7ca6 Mon Sep 17 00:00:00 2001 From: Pratik Prajapati Date: Tue, 5 Sep 2017 12:27:33 -0700 Subject: [PATCH] soc/intel/common/sgx: Fix null pointer dereference warning from klocwork Fix the warnings of klocwork scan. e.g. "Pointer 'dev' checked for NULL at line 158 will be dereferenced at line 159" Change-Id: I6cc9c68652b074c666c86456183460ca38a886ed Signed-off-by: Pratik Prajapati Reviewed-on: https://review.coreboot.org/21408 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Paul Menzel --- src/soc/intel/common/block/sgx/sgx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/soc/intel/common/block/sgx/sgx.c b/src/soc/intel/common/block/sgx/sgx.c index da84ea6119..ec1b6386df 100644 --- a/src/soc/intel/common/block/sgx/sgx.c +++ b/src/soc/intel/common/block/sgx/sgx.c @@ -41,8 +41,14 @@ void prmrr_core_configure(void) msr_t prmrr_mask; msr_t msr; device_t dev = SA_DEV_ROOT; + assert(dev != NULL); config_t *conf = dev->chip_info; + if (!conf) { + printk(BIOS_ERR, "SGX: failed to get chip_info\n"); + return; + } + if (!conf->sgx_enable || !is_sgx_supported()) return; @@ -159,6 +165,11 @@ void sgx_configure(void) config_t *conf = dev->chip_info; const void *microcode_patch = intel_mp_current_microcode(); + if (!conf) { + printk(BIOS_ERR, "SGX: failed to get chip_info\n"); + return; + } + if (!conf->sgx_enable || !is_sgx_supported() || !is_prmrr_set()) { printk(BIOS_ERR, "SGX: pre-conditions not met\n"); return;