]> git.proxmox.com Git - mirror_edk2.git/commit - MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
MdeModulePkg PiSmmCoreMemoryAllocLib: Fix a FreePool() assertion issue
authorStar Zeng <star.zeng@intel.com>
Fri, 28 Jul 2017 03:44:54 +0000 (11:44 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 1 Aug 2017 09:44:02 +0000 (17:44 +0800)
commitecf85eb24c62f7864884e3719418d4d22d515135
treea86ebe49604870b35baa171b9ed485b80e143ae6
parent997b2c543751cb4a3473270c1a7016ade311f01b
MdeModulePkg PiSmmCoreMemoryAllocLib: Fix a FreePool() assertion issue

When PiSmmCore links against PeiDxeDebugLibReportStatusCode, the code
flow below will cause a FreePool() assertion issue.

PiSmmCoreMemoryAllocationLibConstructor() ->
SmmInitializeMemoryServices() ->
DEBUG ((DEBUG_INFO, "SmmAddMemoryRegion\n")) in SmmAddMemoryRegion() ->
DebugPrint() -> REPORT_STATUS_CODE_EX() -> ReportStatusCodeEx() ->
AllocatePool()/FreePool(PiSmmCoreMemoryAllocLib) ->
ASSERT() at Head = CR (Buffer, POOL_HEAD, Data, POOL_HEAD_SIGNATURE)
  in CoreFreePoolI() of DxeCore Pool.c

It is because at the point of FreePool() in the code flow above,
mSmmCoreMemoryAllocLibSmramRanges/mSmmCoreMemoryAllocLibSmramRangeCount
are not been initialized yet, the FreePool() will be directed to
gBS->FreePool(), that is wrong.

This patch is to temporarily use BootServicesData to hold the
SmramRanges data before calling SmmInitializeMemoryServices().

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c