From: Ranbir Singh <[email protected]>
In the function PromoteGuardedFreePages(), the value of AvailablePages
cannot be ZERO at the condition check point
if (AvailablePages != 0) {
as the code can come out of the while loop above only when AvailablePages
is non-ZERO.
Hence, remove the redundant condition check and the return FALSE;
DEADCODE statement at the end of the function.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4219
Cc: Dandan Bi <[email protected]>
Cc: Liming Gao <[email protected]>
Co-authored-by: Veeresh Sangolli <[email protected]>
Signed-off-by: Ranbir Singh <[email protected]>
Signed-off-by: Ranbir Singh <[email protected]>
---
MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 35 +++++++++-----------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index 0c0ca61872b4..016791ee002b 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -1568,28 +1568,25 @@ PromoteGuardedFreePages (
}
}
- if (AvailablePages != 0) {
- DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start,
(UINT64)AvailablePages));
- ClearGuardedMemoryBits (Start, AvailablePages);
+ DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start,
(UINT64)AvailablePages));
+ ClearGuardedMemoryBits (Start, AvailablePages);
- if (gCpu != NULL) {
- //
- // Set flag to make sure allocating memory without GUARD for page table
- // operation; otherwise infinite loops could be caused.
- //
- mOnGuarding = TRUE;
- Status = gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO_SIZE
(AvailablePages), 0);
- ASSERT_EFI_ERROR (Status);
- mOnGuarding = FALSE;
- }
-
- mLastPromotedPage = Start;
- *StartAddress = Start;
- *EndAddress = Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1;
- return TRUE;
+ if (gCpu != NULL) {
+ //
+ // Set flag to make sure allocating memory without GUARD for page table
+ // operation; otherwise infinite loops could be caused.
+ //
+ mOnGuarding = TRUE;
+ Status = gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO_SIZE
(AvailablePages), 0);
+ ASSERT_EFI_ERROR (Status);
+ mOnGuarding = FALSE;
}
- return FALSE;
+ mLastPromotedPage = Start;
+ *StartAddress = Start;
+ *EndAddress = Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1;
+
+ return TRUE;
}
/**
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109062): https://edk2.groups.io/g/devel/message/109062
Mute This Topic: https://groups.io/mt/101590756/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-