]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
Remove SafeFreePool from MemoryAllocationLib as this API's name is misleading. Its...
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / ConfigRouting.c
index 59c2b15109cf1fe31e88d7ae7ac0faec1e0ba620..aed93be1f03f7e2c0db37f5e9025d5d9aee27c76 100644 (file)
@@ -127,13 +127,13 @@ GetDevicePath (
   Length /= 2;\r
   *DevicePath = (UINT8 *) AllocateZeroPool (Length);\r
   if (*DevicePath == NULL) {\r
-    SafeFreePool (DevicePathString);\r
+    FreePool (DevicePathString);\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   HexStringToBufInReverseOrder (*DevicePath, &Length, DevicePathString);\r
 \r
-  SafeFreePool (DevicePathString);\r
+  FreePool (DevicePathString);\r
 \r
   return EFI_SUCCESS;\r
 \r
@@ -202,7 +202,9 @@ ExportAllStorage (
                );\r
   }\r
   if (EFI_ERROR (Status)) {\r
-    SafeFreePool (HandleBuffer);\r
+    if (HandleBuffer != NULL) {\r
+      FreePool (HandleBuffer);\r
+    }\r
     return Status;\r
   }\r
 \r
@@ -219,8 +221,8 @@ ExportAllStorage (
       Status = HiiExportPackageLists (HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
     }\r
     if (EFI_ERROR (Status)) {\r
-      SafeFreePool (HandleBuffer);\r
-      SafeFreePool (HiiPackageList);\r
+      FreePool (HandleBuffer);\r
+      FreePool (HiiPackageList);\r
       return Status;\r
     }\r
 \r
@@ -270,9 +272,9 @@ ExportAllStorage (
 \r
         Status = HiiGetPackageListHandle (HiiDatabase, HiiHandle, &DriverHandle);\r
         if (EFI_ERROR (Status)) {\r
-          SafeFreePool (HandleBuffer);\r
-          SafeFreePool (HiiPackageList);\r
-          SafeFreePool (Storage);\r
+          FreePool (HandleBuffer);\r
+          FreePool (HiiPackageList);\r
+          FreePool (Storage);\r
           return Status;\r
         }\r
         Storage->DriverHandle = DriverHandle;\r
@@ -305,10 +307,10 @@ ExportAllStorage (
       }\r
     }\r
 \r
-    SafeFreePool (HiiPackageList);\r
+    FreePool (HiiPackageList);\r
   }\r
 \r
-  SafeFreePool (HandleBuffer);\r
+  FreePool (HandleBuffer);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -603,7 +605,9 @@ GetValueOfNumber (
   Status  = EFI_SUCCESS;\r
 \r
 Exit:\r
-  SafeFreePool (Str);\r
+  if (Str != NULL) {\r
+    FreePool (Str);\r
+  }\r
   return Status;\r
 }\r
 \r
@@ -738,7 +742,7 @@ HiiConfigRoutingExtractConfig (
     //\r
     Status = GetDevicePath (ConfigRequest, (UINT8 **) &DevicePath);\r
     if (EFI_ERROR (Status)) {\r
-      SafeFreePool (ConfigRequest);\r
+      FreePool (ConfigRequest);\r
       return Status;\r
     }\r
 \r
@@ -765,7 +769,7 @@ HiiConfigRoutingExtractConfig (
       }\r
     }\r
 \r
-    SafeFreePool (DevicePath);\r
+    FreePool (DevicePath);\r
 \r
     if (DriverHandle == NULL) {\r
       //\r
@@ -773,7 +777,7 @@ HiiConfigRoutingExtractConfig (
       // Set Progress to the 'G' in "GUID" of the routing header.\r
       //\r
       *Progress = StringPtr;\r
-      SafeFreePool (ConfigRequest);\r
+      FreePool (ConfigRequest);\r
       return EFI_NOT_FOUND;\r
     }\r
 \r
@@ -802,7 +806,7 @@ HiiConfigRoutingExtractConfig (
       for (TmpPtr = StringPtr; CompareMem (TmpPtr, AccessProgress, RemainSize) != 0; TmpPtr++);\r
       *Progress = TmpPtr;\r
 \r
-      SafeFreePool (ConfigRequest);\r
+      FreePool (ConfigRequest);\r
       return Status;\r
     }\r
 \r
@@ -812,9 +816,9 @@ HiiConfigRoutingExtractConfig (
     ASSERT (*AccessProgress == 0);\r
     Status = AppendToMultiString (Results, AccessResults);\r
     ASSERT_EFI_ERROR (Status);\r
-    SafeFreePool (AccessResults);\r
+    FreePool (AccessResults);\r
     AccessResults = NULL;\r
-    SafeFreePool (ConfigRequest);\r
+    FreePool (ConfigRequest);\r
     ConfigRequest = NULL;\r
 \r
     //\r
@@ -951,7 +955,7 @@ HiiConfigRoutingExportConfig (
     \r
     ConfigRequest = (EFI_STRING) AllocateZeroPool (RequestSize);\r
     if (ConfigRequest == NULL) {\r
-      SafeFreePool (PathHdr);\r
+      FreePool (PathHdr);\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
@@ -997,7 +1001,7 @@ HiiConfigRoutingExportConfig (
     StringPtr += StrLen (L"PATH=");\r
     StrCpy (StringPtr, PathHdr);\r
 \r
-    SafeFreePool (PathHdr);\r
+    FreePool (PathHdr);\r
     PathHdr = NULL;\r
 \r
     //\r
@@ -1021,6 +1025,8 @@ HiiConfigRoutingExportConfig (
                     );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
+    AccessProgress = NULL;\r
+    AccessResults  = NULL;\r
     Status = ConfigAccess->ExtractConfig (\r
                              ConfigAccess,\r
                              ConfigRequest,\r
@@ -1028,8 +1034,13 @@ HiiConfigRoutingExportConfig (
                              &AccessResults\r
                              );\r
     if (EFI_ERROR (Status)) {\r
-      SafeFreePool (ConfigRequest);\r
-      SafeFreePool (AccessResults);\r
+      FreePool (ConfigRequest);\r
+      if (AccessProgress != NULL) {\r
+        FreePool (AccessProgress);\r
+      }\r
+      if (AccessResults != NULL) {\r
+        FreePool (AccessResults);\r
+      }\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -1039,9 +1050,9 @@ HiiConfigRoutingExportConfig (
     ASSERT (*AccessProgress == 0);\r
     Status = AppendToMultiString (Results, AccessResults);\r
     ASSERT_EFI_ERROR (Status);\r
-    SafeFreePool (AccessResults);\r
+    FreePool (AccessResults);\r
     AccessResults = NULL;\r
-    SafeFreePool (ConfigRequest);\r
+    FreePool (ConfigRequest);\r
     ConfigRequest = NULL;\r
 \r
   }\r
@@ -1057,8 +1068,8 @@ HiiConfigRoutingExportConfig (
                 HII_FORMSET_STORAGE_SIGNATURE\r
                 );\r
     RemoveEntryList (&Storage->Entry);\r
-    SafeFreePool (Storage->Name);\r
-    SafeFreePool (Storage);\r
+    FreePool (Storage->Name);\r
+    FreePool (Storage);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -1173,7 +1184,7 @@ HiiConfigRoutingRouteConfig (
     //\r
     Status = GetDevicePath (ConfigResp, (UINT8 **) &DevicePath);\r
     if (EFI_ERROR (Status)) {\r
-      SafeFreePool (ConfigResp);\r
+      FreePool (ConfigResp);\r
       return Status;\r
     }\r
 \r
@@ -1200,7 +1211,7 @@ HiiConfigRoutingRouteConfig (
       }\r
     }\r
 \r
-    SafeFreePool (DevicePath);\r
+    FreePool (DevicePath);\r
 \r
     if (DriverHandle == NULL) {\r
       //\r
@@ -1208,7 +1219,7 @@ HiiConfigRoutingRouteConfig (
       // Set Progress to the 'G' in "GUID" of the routing header.\r
       //\r
       *Progress = StringPtr;\r
-      SafeFreePool (ConfigResp);\r
+      FreePool (ConfigResp);\r
       return EFI_NOT_FOUND;\r
     }\r
 \r
@@ -1237,11 +1248,11 @@ HiiConfigRoutingRouteConfig (
       for (TmpPtr = StringPtr; CompareMem (TmpPtr, AccessProgress, RemainSize) != 0; TmpPtr++);\r
       *Progress = TmpPtr;\r
 \r
-      SafeFreePool (ConfigResp);\r
+      FreePool (ConfigResp);\r
       return Status;\r
     }\r
 \r
-    SafeFreePool (ConfigResp);\r
+    FreePool (ConfigResp);\r
     ConfigResp = NULL;\r
 \r
     //\r
@@ -1408,7 +1419,7 @@ HiiBlockToConfig (
       TmpBuffer,\r
       (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
       );\r
-    SafeFreePool (TmpBuffer);\r
+    FreePool (TmpBuffer);\r
 \r
     StringPtr += Length;\r
     if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {\r
@@ -1432,7 +1443,7 @@ HiiBlockToConfig (
       TmpBuffer,\r
       (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
       );\r
-    SafeFreePool (TmpBuffer);\r
+    FreePool (TmpBuffer);\r
 \r
     StringPtr += Length;\r
     if (*StringPtr != 0 && *StringPtr != L'&') {\r
@@ -1471,7 +1482,7 @@ HiiBlockToConfig (
     ASSERT_EFI_ERROR (Status);\r
     ToLower (ValueStr);\r
 \r
-    SafeFreePool (Value);\r
+    FreePool (Value);\r
     Value = NULL;\r
 \r
     //\r
@@ -1493,8 +1504,8 @@ HiiBlockToConfig (
 \r
     AppendToMultiString (Config, ConfigElement);\r
 \r
-    SafeFreePool (ConfigElement);\r
-    SafeFreePool (ValueStr);\r
+    FreePool (ConfigElement);\r
+    FreePool (ValueStr);\r
     ConfigElement = NULL;\r
     ValueStr = NULL;\r
 \r
@@ -1519,11 +1530,16 @@ HiiBlockToConfig (
   return EFI_SUCCESS;\r
 \r
 Exit:\r
-\r
-  SafeFreePool (*Config);\r
-  SafeFreePool (ValueStr);\r
-  SafeFreePool (Value);\r
-  SafeFreePool (ConfigElement);\r
+  FreePool (*Config);\r
+  if (ValueStr != NULL) {\r
+    FreePool (ValueStr);\r
+  }\r
+  if (Value != NULL) {\r
+    FreePool (Value);\r
+  }\r
+  if (ConfigElement) {\r
+    FreePool (ConfigElement);\r
+  }\r
 \r
   return Status;\r
 \r
@@ -1658,7 +1674,7 @@ HiiConfigToBlock (
       TmpBuffer,\r
       (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
       );\r
-    SafeFreePool (TmpBuffer);\r
+    FreePool (TmpBuffer);\r
 \r
     StringPtr += Length;\r
     if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {\r
@@ -1682,7 +1698,7 @@ HiiConfigToBlock (
       TmpBuffer,\r
       (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
       );\r
-    SafeFreePool (TmpBuffer);\r
+    FreePool (TmpBuffer);\r
 \r
     StringPtr += Length;\r
     if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) {\r
@@ -1719,7 +1735,7 @@ HiiConfigToBlock (
     CopyMem (Block + Offset, Value, Width);\r
     *BlockSize = Offset + Width - 1;\r
 \r
-    SafeFreePool (Value);\r
+    FreePool (Value);\r
     Value = NULL;\r
 \r
     //\r
@@ -1743,7 +1759,9 @@ HiiConfigToBlock (
 \r
 Exit:\r
 \r
-  SafeFreePool (Value);\r
+  if (Value != NULL) {\r
+    FreePool (Value);\r
+  }\r
   return Status;\r
 }\r
 \r
@@ -1983,11 +2001,21 @@ Exit:
     }\r
   }\r
 \r
-  SafeFreePool (GuidStr);\r
-  SafeFreePool (NameStr);\r
-  SafeFreePool (PathStr);\r
-  SafeFreePool (AltIdStr);\r
-  SafeFreePool (Result);\r
+  if (GuidStr != NULL) {\r
+    FreePool (GuidStr);\r
+  }\r
+  if (NameStr != NULL) {\r
+    FreePool (NameStr);\r
+  }\r
+  if (PathStr != NULL) {\r
+    FreePool (PathStr);\r
+  }\r
+  if (AltIdStr != NULL) {\r
+    FreePool (AltIdStr);\r
+  }\r
+  if (Result != NULL) {\r
+    FreePool (Result);\r
+  }\r
 \r
   return Status;\r
 \r