diff options
author | Phil Noh <Phil.Noh@amd.com> | 2024-12-04 12:20:35 -0600 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-12-06 10:17:16 +0000 |
commit | e508c6c08ab6a97ba8c34a156e17bcd9600104dd (patch) | |
tree | ec1f370ef02316474c0cdbcf8cd251db67efb2be | |
parent | 73570d8ab6798f8c68c5223d9818f74710d8ed74 (diff) | |
download | edk2-e508c6c08ab6a97ba8c34a156e17bcd9600104dd.tar.gz |
MdeModulePkg/DxeIplPeim: Free scratch buffer after FV extraction
The scratch buffer (EfiBootServicesData) is assigned to extract DXE FVs
that are compressed. The matching decompression library returns the buffer
size as below. The buffer is no longer used after completing extraction.
Need to free the buffer to optimize memory allocation and usage.
BaseUefiDecompressLib : sizeof (SCRATCH_DATA)
LzmaCustomDecompressLib : SCRATCH_BUFFER_REQUEST_SIZE (64KB)
BrotliCustomDecompressLib : From EncodeData header (usually, xxMB checked)
In case of Brotli decompression, it is found that a big chunk of memory is
required, based on EncodeData header. (e.g. a 4MB compressed FV reports
about 39MB scratch size)
Signed-off-by: Phil Noh <Phil.Noh@amd.com>
-rw-r--r-- | MdeModulePkg/Core/DxeIplPeim/DxeLoad.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c index 933b245036..b9fe70332e 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -636,6 +636,11 @@ CustomGuidedSectionExtract ( ScratchBuffer,
AuthenticationStatus
);
+
+ if (ScratchBuffer != NULL) {
+ FreePages (ScratchBuffer, EFI_SIZE_TO_PAGES (ScratchBufferSize));
+ }
+
if (EFI_ERROR (Status)) {
//
// Decode failed
|