Skip to content

Commit 28653a1

Browse files
zhouji3xmergify[bot]
authored andcommitted
UefiCpuPkg/PiSmmCpuDxeSmm: Fix SMRAM memory leak during S3 resume
SyncContext of SMM_DISPATCHER_MP_SYNC_DATA was dynamically allocated from SMRAM. The memory was not freed before reallocation in S3 resume path. This could lead to: 1. Memory leak in SMRAM. 2. Potential S3 resume failure after repeated S3 tests due to SMRAM exhaustion. This change releases the SyncContext memory before reallocating it Signed-off-by: Zhou Jianfeng <[email protected]>
1 parent d6101ac commit 28653a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

+5
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,10 @@ InitializeMpSyncData (
18681868
UINTN CpuIndex;
18691869

18701870
if (mSmmMpSyncData != NULL) {
1871+
if (mSmmMpSyncData->SyncContext != NULL) {
1872+
SmmCpuSyncContextDeinit (mSmmMpSyncData->SyncContext);
1873+
}
1874+
18711875
//
18721876
// mSmmMpSyncDataSize includes one structure of SMM_DISPATCHER_MP_SYNC_DATA, one
18731877
// CpuData array of SMM_CPU_DATA_BLOCK and one CandidateBsp array of BOOLEAN.
@@ -1968,6 +1972,7 @@ InitializeMpServiceData (
19681972
mSmmMpSyncData = (SMM_DISPATCHER_MP_SYNC_DATA *)AllocatePages (EFI_SIZE_TO_PAGES (mSmmMpSyncDataSize));
19691973
ASSERT (mSmmMpSyncData != NULL);
19701974

1975+
ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize);
19711976
RelaxedMode = FALSE;
19721977
GetSmmCpuSyncConfigData (&RelaxedMode, NULL, NULL);
19731978
mCpuSmmSyncMode = RelaxedMode ? MmCpuSyncModeRelaxedAp : MmCpuSyncModeTradition;

0 commit comments

Comments
 (0)