]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
Remove SafeFreePool from MemoryAllocationLib as this API's name is misleading. Its...
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMaint / BootOption.c
index 020d63a8c615a5e9791c5514f615c2a78f99ff68..85ba61707faa4afa5cec427deeb1b196f6065098 100644 (file)
@@ -83,7 +83,7 @@ BOpt_CreateMenuEntry (
 \r
   MenuEntry->VariableContext = AllocateZeroPool (ContextSize);\r
   if (NULL == MenuEntry->VariableContext) {\r
-    SafeFreePool (MenuEntry);\r
+    FreePool (MenuEntry);\r
     return NULL;\r
   }\r
 \r
@@ -116,59 +116,65 @@ BOpt_DestroyMenuEntry (
   switch (MenuEntry->ContextSelection) {\r
   case BM_LOAD_CONTEXT_SELECT:\r
     LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;\r
-    SafeFreePool (LoadContext->FilePathList);\r
-    SafeFreePool (LoadContext->LoadOption);\r
-    SafeFreePool (LoadContext->OptionalData);\r
-    SafeFreePool (LoadContext);\r
+    FreePool (LoadContext->FilePathList);\r
+    FreePool (LoadContext->LoadOption);\r
+    if (LoadContext->OptionalData != NULL) {\r
+      FreePool (LoadContext->OptionalData);\r
+    }\r
+    FreePool (LoadContext);\r
     break;\r
 \r
   case BM_FILE_CONTEXT_SELECT:\r
     FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
 \r
     if (!FileContext->IsRoot) {\r
-      SafeFreePool (FileContext->DevicePath);\r
+      FreePool (FileContext->DevicePath);\r
     } else {\r
       if (FileContext->FHandle != NULL) {\r
         FileContext->FHandle->Close (FileContext->FHandle);\r
       }\r
     }\r
 \r
-    SafeFreePool (FileContext->FileName);\r
-    SafeFreePool (FileContext->Info);\r
-    SafeFreePool (FileContext);\r
+    if (FileContext->FileName != NULL) {\r
+      FreePool (FileContext->FileName);\r
+    }\r
+    if (FileContext->Info != NULL) {\r
+      FreePool (FileContext->Info);\r
+    }\r
+    FreePool (FileContext);\r
     break;\r
 \r
   case BM_CONSOLE_CONTEXT_SELECT:\r
     ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;\r
-    SafeFreePool (ConsoleContext->DevicePath);\r
-    SafeFreePool (ConsoleContext);\r
+    FreePool (ConsoleContext->DevicePath);\r
+    FreePool (ConsoleContext);\r
     break;\r
 \r
   case BM_TERMINAL_CONTEXT_SELECT:\r
     TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;\r
-    SafeFreePool (TerminalContext->DevicePath);\r
-    SafeFreePool (TerminalContext);\r
+    FreePool (TerminalContext->DevicePath);\r
+    FreePool (TerminalContext);\r
     break;\r
 \r
   case BM_HANDLE_CONTEXT_SELECT:\r
     HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;\r
-    SafeFreePool (HandleContext);\r
+    FreePool (HandleContext);\r
     break;\r
 \r
   case BM_LEGACY_DEV_CONTEXT_SELECT:\r
     LegacyDevContext = (BM_LEGACY_DEVICE_CONTEXT *) MenuEntry->VariableContext;\r
-    SafeFreePool (LegacyDevContext);\r
+    FreePool (LegacyDevContext);\r
 \r
   default:\r
     break;\r
   }\r
 \r
-  SafeFreePool (MenuEntry->DisplayString);\r
+  FreePool (MenuEntry->DisplayString);\r
   if (NULL != MenuEntry->HelpString) {\r
-    SafeFreePool (MenuEntry->HelpString);\r
+    FreePool (MenuEntry->HelpString);\r
   }\r
 \r
-  SafeFreePool (MenuEntry);\r
+  FreePool (MenuEntry);\r
 }\r
 \r
 /**\r
@@ -278,7 +284,7 @@ BOpt_FindFileSystem (
       if (BlkIo->Media->RemovableMedia) {\r
         Buffer = AllocateZeroPool (BlkIo->Media->BlockSize);\r
         if (NULL == Buffer) {\r
-          SafeFreePool (BlkIoHandle);\r
+          FreePool (BlkIoHandle);\r
           return EFI_OUT_OF_RESOURCES;\r
         }\r
 \r
@@ -289,10 +295,10 @@ BOpt_FindFileSystem (
                 BlkIo->Media->BlockSize,\r
                 Buffer\r
                 );\r
-        SafeFreePool (Buffer);\r
+        FreePool (Buffer);\r
       }\r
     }\r
-    SafeFreePool (BlkIoHandle);\r
+    FreePool (BlkIoHandle);\r
   }\r
 \r
   //\r
@@ -332,7 +338,7 @@ BOpt_FindFileSystem (
       //\r
       MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
       if (NULL == MenuEntry) {\r
-        SafeFreePool (SimpleFsHandle);\r
+        FreePool (SimpleFsHandle);\r
         return EFI_OUT_OF_RESOURCES;\r
       }\r
 \r
@@ -390,7 +396,7 @@ BOpt_FindFileSystem (
   }\r
 \r
   if (NoSimpleFsHandles != 0) {\r
-    SafeFreePool (SimpleFsHandle);\r
+    FreePool (SimpleFsHandle);\r
   }\r
   //\r
   // Searching for handles that support Load File protocol\r
@@ -407,7 +413,7 @@ BOpt_FindFileSystem (
     for (Index = 0; Index < NoLoadFileHandles; Index++) {\r
       MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
       if (NULL == MenuEntry) {\r
-        SafeFreePool (LoadFileHandle);\r
+        FreePool (LoadFileHandle);\r
         return EFI_OUT_OF_RESOURCES;\r
       }\r
 \r
@@ -438,7 +444,7 @@ BOpt_FindFileSystem (
   }\r
 \r
   if (NoLoadFileHandles != 0) {\r
-    SafeFreePool (LoadFileHandle);\r
+    FreePool (LoadFileHandle);\r
   }\r
 \r
   //\r
@@ -676,7 +682,7 @@ BOpt_FindFiles (
   }\r
 \r
   DirectoryMenu.MenuNumber = OptionNumber;\r
-  SafeFreePool (DirInfo);\r
+  FreePool (DirInfo);\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -898,7 +904,7 @@ BOpt_GetBootOptions (
 \r
   if (BootNext != NULL) {\r
     if (BootNextSize != sizeof (UINT16)) {\r
-      SafeFreePool (BootNext);\r
+      FreePool (BootNext);\r
       BootNext = NULL;\r
     }\r
   }\r
@@ -923,7 +929,7 @@ BOpt_GetBootOptions (
     }\r
 \r
     CopyMem (LoadOption, LoadOptionFromVar, BootOptionSize);\r
-    SafeFreePool (LoadOptionFromVar);\r
+    FreePool (LoadOptionFromVar);\r
 \r
     if (BootNext != NULL) {\r
       BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);\r
@@ -932,7 +938,7 @@ BOpt_GetBootOptions (
     }\r
 \r
     if (0 == (*((UINT32 *) LoadOption) & LOAD_OPTION_ACTIVE)) {\r
-      SafeFreePool (LoadOption);\r
+      FreePool (LoadOption);\r
       continue;\r
     }\r
     //\r
@@ -1054,8 +1060,12 @@ BOpt_GetBootOptions (
     MenuCount++;\r
   }\r
 \r
-  SafeFreePool (BootNext);\r
-  SafeFreePool (BootOrderList);\r
+  if (BootNext != NULL) {\r
+    FreePool (BootNext);\r
+  }\r
+  if (BootOrderList != NULL) {\r
+    FreePool (BootOrderList);\r
+  }\r
   BootOptionMenu.MenuNumber = MenuCount;\r
   return MenuCount;\r
 }\r
@@ -1318,7 +1328,7 @@ BOpt_FindDrivers (
 \r
     NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);\r
     if (NULL == NewMenuEntry) {\r
-      SafeFreePool (DevicePathHandle);\r
+      FreePool (DevicePathHandle);\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
@@ -1332,7 +1342,10 @@ BOpt_FindDrivers (
     InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);\r
 \r
   }\r
-  SafeFreePool (DevicePathHandle);\r
+\r
+  if (DevicePathHandle != NULL) {\r
+    FreePool (DevicePathHandle);\r
+  }\r
 \r
   DriverMenu.MenuNumber = OptionNumber;\r
   return EFI_SUCCESS;\r
@@ -1545,7 +1558,7 @@ BOpt_GetDriverOptions (
     }\r
 \r
     CopyMem (LoadOption, LoadOptionFromVar, DriverOptionSize);\r
-    SafeFreePool (LoadOptionFromVar);\r
+    FreePool (LoadOptionFromVar);\r
 \r
     NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
     if (NULL == NewMenuEntry) {\r
@@ -1631,7 +1644,9 @@ BOpt_GetDriverOptions (
 \r
   }\r
 \r
-  SafeFreePool (DriverOrderList);\r
+  if (DriverOrderList != NULL) {\r
+    FreePool (DriverOrderList);\r
+  }\r
   DriverOptionMenu.MenuNumber = Index;\r
   return EFI_SUCCESS;\r
 \r