]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootOption.c
ArmPlatformPkg: Fixed memory leak after calling GetEnvironmentVariable()
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootOption.c
index e562add3d1ab8f084ad0ed0d60d713765de48402..8993cb14a21a512ba0a66a4392c44c0c2a056d2c 100644 (file)
@@ -12,6 +12,7 @@
 *\r
 **/\r
 \r
+#include <Guid/ArmGlobalVariableHob.h>\r
 #include "BdsInternal.h"\r
 \r
 extern EFI_HANDLE mImageHandle;\r
@@ -76,7 +77,8 @@ BootOptionStart (
 \r
       // Get the FDT device path\r
       FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);\r
-      Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);\r
+      Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid,\r
+                 DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);\r
       ASSERT_EFI_ERROR(Status);\r
 \r
       Status = BdsBootLinuxFdt (BootOption->FilePathList,\r
@@ -84,6 +86,7 @@ BootOptionStart (
                                 (CHAR8*)(LinuxArguments + 1),\r
                                 FdtDevicePath);\r
 \r
+      FreePool (DefaultFdtDevicePath);\r
       FreePool (FdtDevicePath);\r
     }\r
   } else {\r
@@ -120,7 +123,7 @@ BootOptionList (
   InitializeListHead (BootOptionList);\r
 \r
   // Get the Boot Option Order from the environment variable\r
-  Status = GetEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);\r
+  Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);\r
   if (EFI_ERROR(Status)) {\r
     return Status;\r
   }\r
@@ -286,7 +289,7 @@ BootOptionCreate (
       );\r
 \r
   // Add the new Boot Index to the list\r
-  Status = GetEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);\r
+  Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);\r
   if (!EFI_ERROR(Status)) {\r
     BootOrder = ReallocatePool (BootOrderSize, BootOrderSize + sizeof(UINT16), BootOrder);\r
     // Add the new index at the end\r
@@ -358,7 +361,7 @@ BootOptionDelete (
   EFI_STATUS    Status;\r
 \r
   // Remove the entry from the BootOrder environment variable\r
-  Status = GetEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);\r
+  Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);\r
   if (!EFI_ERROR(Status)) {\r
     BootOrderCount = BootOrderSize / sizeof(UINT16);\r
 \r