From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 85BB48213E for ; Mon, 19 Dec 2016 18:22:19 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 19 Dec 2016 18:22:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,376,1477983600"; d="scan'208";a="204769693" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga004.fm.intel.com with ESMTP; 19 Dec 2016 18:22:17 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Jiewen Yao , Jeff Fan , Michael Kinney Date: Tue, 20 Dec 2016 10:22:16 +0800 Message-Id: <1482200536-11784-1-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 Subject: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2016 02:22:19 -0000 Cc: Jiewen Yao Cc: Jeff Fan Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index f4716f3..d967255 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -1011,6 +1011,10 @@ GetUefiMemoryMap ( } } while (Status == EFI_BUFFER_TOO_SMALL); + if (MemoryMap == NULL) { + return ; + } + SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize); MergeMemoryMapForNotPresentEntry (MemoryMap, &UefiMemoryMapSize, mUefiDescriptorSize); @@ -1080,6 +1084,13 @@ IsSmmCommBufferForbiddenAddress ( UINTN MemoryMapEntryCount; UINTN Index; + DEBUG ((DEBUG_INFO, "IsSmmCommBufferForbiddenAddress\n")); + + if (mUefiMemoryMap == NULL) { + DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n")); + return FALSE; + } + MemoryMap = mUefiMemoryMap; MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize; for (Index = 0; Index < MemoryMapEntryCount; Index++) { -- 1.9.5.msysgit.0