]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c
MdeModulePkg:Prevent the BmRepairAllControllers routine in an infinite loop
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmDriverHealth.c
index d197816fa1fa99ab6ed74c1c414cdbeedb4fb744..1e68cbc01f9a3992b27b4be95c01a40dd5a7b386 100644 (file)
@@ -2,6 +2,8 @@
   Library functions which relates with driver health.\r
 \r
 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -76,7 +78,7 @@ BmGetControllerName (
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
-    LanguageVariable = GetEfiGlobalVariable (Iso639Language ? L"Lang" : L"PlatformLang");\r
+    GetEfiGlobalVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", (VOID**)&LanguageVariable, NULL);\r
     BestLanguage     = GetBestLanguage(\r
                          ComponentName->SupportedLanguages,\r
                          Iso639Language,\r
@@ -295,7 +297,6 @@ EfiBootManagerGetDriverHealthInfo (
   EFI_STATUS                 Status;\r
   UINTN                      NumHandles;\r
   EFI_HANDLE                 *DriverHealthHandles;\r
-  EFI_DRIVER_HEALTH_STATUS   HealthStatus;\r
   UINTN                      DriverHealthIndex;\r
   EFI_HANDLE                 *Handles;\r
   UINTN                      HandleCount;\r
@@ -313,8 +314,6 @@ EfiBootManagerGetDriverHealthInfo (
   NumHandles              = 0;\r
   HandleCount             = 0;\r
 \r
-  HealthStatus = EfiDriverHealthStatusHealthy;\r
-\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
                   &gEfiDriverHealthProtocolGuid,\r
@@ -441,6 +440,8 @@ BmRepairAllControllers (
   BOOLEAN                             RebootRequired;\r
   EFI_HII_HANDLE                      *HiiHandles;\r
   EFI_FORM_BROWSER2_PROTOCOL          *FormBrowser2;\r
+  UINT32                              MaxRepairCount;\r
+  UINT32                              RepairCount;\r
 \r
   //\r
   // Configure PcdDriverHealthConfigureForm to ZeroGuid to disable driver health check.\r
@@ -452,6 +453,9 @@ BmRepairAllControllers (
   Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  MaxRepairCount = PcdGet32 (PcdMaxRepairCount);\r
+  RepairCount = 0;\r
+\r
   do {\r
     RepairRequired        = FALSE;\r
     ConfigurationRequired = FALSE;\r
@@ -514,7 +518,8 @@ BmRepairAllControllers (
     }\r
   \r
     EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);\r
-  } while (RepairRequired || ConfigurationRequired);\r
+    RepairCount++;\r
+  } while ((RepairRequired || ConfigurationRequired) && ((MaxRepairCount == 0) || (RepairCount < MaxRepairCount)));\r
 \r
   RebootRequired    = FALSE;\r
   ReconnectRequired = FALSE;\r