From 7422411e38523446c3d0e6b37bfbaaf90d8726f7 Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Wed, 4 Jul 2012 20:21:13 +0000 Subject: [PATCH] ArmPkg/BdsLib: Fixed ShutdownUefiBootServices() in case the first gBS->GetMemoryMap() was successful If the first call of gBS->GetMemoryMap() succeeded (could happen if the Memory Map has changed between the two gBS->GetMemoryMap() calls) in the loop block then gBS->ExitBootServices() was never called. Signed-off-by: Eugene Cohen Reviewed-by: Olivier Martin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13500 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Library/BdsLib/BdsHelper.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ArmPkg/Library/BdsLib/BdsHelper.c b/ArmPkg/Library/BdsLib/BdsHelper.c index d971a76b71..bd1fa005e8 100644 --- a/ArmPkg/Library/BdsLib/BdsHelper.c +++ b/ArmPkg/Library/BdsLib/BdsHelper.c @@ -43,6 +43,7 @@ ShutdownUefiBootServices ( MemoryMap = NULL; MemoryMapSize = 0; + Pages = 0; do { Status = gBS->GetMemoryMap ( &MemoryMapSize, @@ -66,17 +67,18 @@ ShutdownUefiBootServices ( &DescriptorSize, &DescriptorVersion ); - // Don't do anything between the GetMemoryMap() and ExitBootServices() - if (!EFI_ERROR (Status)) { - Status = gBS->ExitBootServices (gImageHandle, MapKey); - if (EFI_ERROR (Status)) { - FreePages (MemoryMap, Pages); - MemoryMap = NULL; - MemoryMapSize = 0; - } + } + + // Don't do anything between the GetMemoryMap() and ExitBootServices() + if (!EFI_ERROR(Status)) { + Status = gBS->ExitBootServices (gImageHandle, MapKey); + if (EFI_ERROR(Status)) { + FreePages (MemoryMap, Pages); + MemoryMap = NULL; + MemoryMapSize = 0; } } - } while (EFI_ERROR (Status)); + } while (EFI_ERROR(Status)); return Status; }