From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 55E212095E529 for ; Mon, 25 Sep 2017 19:44:55 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 25 Sep 2017 19:48:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,438,1500966000"; d="scan'208";a="153301202" Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.57]) by orsmga005.jf.intel.com with ESMTP; 25 Sep 2017 19:48:03 -0700 From: Eric Dong To: edk2-devel@lists.01.org Cc: Ming Shao , Ruiyu Ni Date: Tue, 26 Sep 2017 10:48:01 +0800 Message-Id: <1506394081-3852-1-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [Patch] UefiCpuPkg/CpuCommonFeaturesLib: Add check for input parameter. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Sep 2017 02:44:56 -0000 The ConfigData parameter initialized in *GetConfigData function should not be NULL in later *Support, *Initilize function, so just add ASSERT code check in these functions. Cc: Ming Shao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong --- UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c | 2 ++ UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c index 178bfb5..880f092 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c @@ -68,6 +68,7 @@ AesniSupport ( IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; + ASSERT (MsrFeatureConfig != NULL); MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG); return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1); } @@ -112,6 +113,7 @@ AesniInitialize ( // if (CpuInfo->ProcessorInfo.Location.Thread == 0) { MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; + ASSERT (MsrFeatureConfig != NULL); if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) { CPU_REGISTER_TABLE_WRITE_FIELD ( ProcessorNumber, diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c index 8a12080..b42f5de 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c @@ -120,6 +120,7 @@ ProcTraceSupport ( // Check if ProcTraceMemorySize option is enabled (0xFF means disable by user) // ProcTraceData = (PROC_TRACE_DATA *) ConfigData; + ASSERT (ProcTraceData != NULL); if ((ProcTraceData->ProcTraceMemSize > RtitTopaMemorySize128M) || (ProcTraceData->ProcTraceOutputScheme > RtitOutputSchemeToPA)) { return FALSE; @@ -191,6 +192,7 @@ ProcTraceInitialize ( RTIT_TOPA_TABLE_ENTRY *TopaEntryPtr; ProcTraceData = (PROC_TRACE_DATA *) ConfigData; + ASSERT (ProcTraceData != NULL); MemRegionBaseAddr = 0; FirstIn = FALSE; -- 2.7.0.windows.1