]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/BdsLib/BdsHelper.c
ArmPkg/BdsLib: Fixed ShutdownUefiBootServices() in case the first gBS->GetMemoryMap...
[mirror_edk2.git] / ArmPkg / Library / BdsLib / BdsHelper.c
index d971a76b7177b10db6d25edf29bf2f83158d1b0c..bd1fa005e83e257943d19e2c31a412508774df1d 100644 (file)
@@ -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;
 }