MdeModulePkg DxeCore/PiSmmCore/MemoryProfileInfo: Fix EBC and VS2013 build failure.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16396 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Star Zeng 2014-11-17 02:30:44 +00:00 committed by lzeng14
parent 1db55d6a82
commit f442002764
3 changed files with 23 additions and 4 deletions

View File

@ -557,6 +557,7 @@ GetUefiMemoryProfileData (
Size = Size + sizeof (MEMORY_PROFILE_ALLOC_INFO); Size = Size + sizeof (MEMORY_PROFILE_ALLOC_INFO);
Data = AllocateZeroPool ((UINTN) Size); Data = AllocateZeroPool ((UINTN) Size);
if (Data == NULL) { if (Data == NULL) {
Status = EFI_OUT_OF_RESOURCES;
Print (L"UefiMemoryProfile: AllocateZeroPool (0x%x) - %r\n", Size, Status); Print (L"UefiMemoryProfile: AllocateZeroPool (0x%x) - %r\n", Size, Status);
return Status; return Status;
} }
@ -597,7 +598,7 @@ GetSmramProfileData (
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN CommSize; UINTN CommSize;
UINT8 CommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA)]; UINT8 *CommBuffer;
EFI_SMM_COMMUNICATE_HEADER *CommHeader; EFI_SMM_COMMUNICATE_HEADER *CommHeader;
SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *CommGetProfileInfo; SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *CommGetProfileInfo;
SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA *CommGetProfileData; SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA *CommGetProfileData;
@ -611,6 +612,14 @@ GetSmramProfileData (
return Status; return Status;
} }
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA);
CommBuffer = AllocateZeroPool (CommSize);
if (CommBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
Print (L"SmramProfile: AllocateZeroPool (0x%x) for comm buffer - %r\n", CommSize, Status);
return Status;
}
// //
// Get Size // Get Size
// //
@ -627,6 +636,7 @@ GetSmramProfileData (
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength; CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;
Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize); Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (CommBuffer);
DEBUG ((EFI_D_ERROR, "SmramProfile: SmmCommunication - %r\n", Status)); DEBUG ((EFI_D_ERROR, "SmramProfile: SmmCommunication - %r\n", Status));
return Status; return Status;
} }
@ -643,8 +653,10 @@ GetSmramProfileData (
// //
ProfileBuffer = (PHYSICAL_ADDRESS) (UINTN) AllocateZeroPool ((UINTN) ProfileSize); ProfileBuffer = (PHYSICAL_ADDRESS) (UINTN) AllocateZeroPool ((UINTN) ProfileSize);
if (ProfileBuffer == 0) { if (ProfileBuffer == 0) {
Print (L"UefiMemoryProfile: AllocateZeroPool (0x%x) - %r\n", (UINTN) ProfileSize, Status); FreePool (CommBuffer);
return EFI_SUCCESS; Status = EFI_OUT_OF_RESOURCES;
Print (L"SmramProfile: AllocateZeroPool (0x%x) for profile buffer - %r\n", (UINTN) ProfileSize, Status);
return Status;
} }
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0]; CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
@ -663,6 +675,8 @@ GetSmramProfileData (
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (CommGetProfileData->Header.ReturnStatus != 0) { if (CommGetProfileData->Header.ReturnStatus != 0) {
FreePool ((VOID *) (UINTN) CommGetProfileData->ProfileBuffer);
FreePool (CommBuffer);
Print (L"GetProfileData - 0x%x\n", CommGetProfileData->Header.ReturnStatus); Print (L"GetProfileData - 0x%x\n", CommGetProfileData->Header.ReturnStatus);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -674,6 +688,7 @@ GetSmramProfileData (
Print (L"======= SmramProfile end =======\n\n\n"); Print (L"======= SmramProfile end =======\n\n\n");
FreePool ((VOID *) (UINTN) CommGetProfileData->ProfileBuffer); FreePool ((VOID *) (UINTN) CommGetProfileData->ProfileBuffer);
FreePool (CommBuffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -817,6 +817,8 @@ CoreUpdateProfileAllocate (
MEMORY_PROFILE_ALLOC_INFO_DATA *AllocInfoData; MEMORY_PROFILE_ALLOC_INFO_DATA *AllocInfoData;
EFI_MEMORY_TYPE ProfileMemoryIndex; EFI_MEMORY_TYPE ProfileMemoryIndex;
AllocInfoData = NULL;
ContextData = GetMemoryProfileContext (); ContextData = GetMemoryProfileContext ();
if (ContextData == NULL) { if (ContextData == NULL) {
return FALSE; return FALSE;

View File

@ -824,6 +824,8 @@ SmmCoreUpdateProfileAllocate (
MEMORY_PROFILE_ALLOC_INFO_DATA *AllocInfoData; MEMORY_PROFILE_ALLOC_INFO_DATA *AllocInfoData;
EFI_MEMORY_TYPE ProfileMemoryIndex; EFI_MEMORY_TYPE ProfileMemoryIndex;
AllocInfoData = NULL;
ContextData = GetSmramProfileContext (); ContextData = GetSmramProfileContext ();
if (ContextData == NULL) { if (ContextData == NULL) {
return FALSE; return FALSE;