diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index bffab83d4f..baa085c384 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -744,10 +744,11 @@ ArmSetMemoryAttributes ( UINT64 ChunkLength; BOOLEAN FlushTlbs; - if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) { + if (BaseAddress > (UINT64)MAX_ADDRESS) { return EFI_UNSUPPORTED; } + Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1); if (Length == 0) { return EFI_SUCCESS; }