From 3d817fd11af6a4981978f6c0d5648ce470aa92b5 Mon Sep 17 00:00:00 2001 From: Jian J Wang Date: Sat, 16 Dec 2017 17:22:35 +0800 Subject: [PATCH] MdeModulePkg/Core: Fix incorrect memory map generated in a rare case The root cause is that mImagePropertiesPrivateData.CodeSegmentCountMax was not updated with correct value due to the fact that SortImageRecord() called before might change the content of current ImageRecord. This will in turn cause incorrect memory map entries generated in SplitTable(). Cc: Star Zeng Cc: Eric Dong Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Reviewed-by: Jiewen Yao --- MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 4 ++-- MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c index 75d9b14c1f..a84507df95 100644 --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -1229,12 +1229,12 @@ InsertImageRecord ( InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link); mImagePropertiesPrivateData.ImageRecordCount++; - SortImageRecord (); - if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) { mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount; } + SortImageRecord (); + Finish: return ; } diff --git a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c index e3c505ef18..36ccf65fa3 100644 --- a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c @@ -1214,12 +1214,12 @@ SmmInsertImageRecord ( InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link); mImagePropertiesPrivateData.ImageRecordCount++; - SortImageRecord (); - if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) { mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount; } + SortImageRecord (); + Finish: return ; }