]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. remove duplicated NetLibDispatchDpc() calling in Pool function.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Jul 2009 06:59:07 +0000 (06:59 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Jul 2009 06:59:07 +0000 (06:59 +0000)
2. use mde library
3. add security check.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8860 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c

index 6a4ac62acdea5a12f1b4eee08ee10b4835272156..5ccbefd4321373257a73f0a68ee5f0338cbf34e2 100644 (file)
@@ -253,7 +253,7 @@ Dhcp4CreateService (
 \r
 ON_ERROR:\r
   Dhcp4CloseService (DhcpSb);\r
-  gBS->FreePool (DhcpSb);\r
+  FreePool (DhcpSb);\r
 \r
   return Status;\r
 }\r
@@ -334,7 +334,7 @@ Dhcp4DriverBindingStart (
 \r
 ON_ERROR:\r
   Dhcp4CloseService (DhcpSb);\r
-  gBS->FreePool (DhcpSb);\r
+  FreePool (DhcpSb);\r
   return Status;\r
 }\r
 \r
@@ -417,7 +417,7 @@ Dhcp4DriverBindingStop (
 \r
     Dhcp4CloseService (DhcpSb);\r
 \r
-    gBS->FreePool (DhcpSb);\r
+    FreePool (DhcpSb);\r
   } else {\r
     //\r
     // Don't use NET_LIST_FOR_EACH_SAFE here, Dhcp4ServiceBindingDestoryChild\r
@@ -522,7 +522,7 @@ Dhcp4ServiceBindingCreateChild (
                   );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (Instance);\r
+    FreePool (Instance);\r
     return Status;\r
   }\r
 \r
@@ -547,7 +547,7 @@ Dhcp4ServiceBindingCreateChild (
            NULL\r
            );\r
 \r
-    gBS->FreePool (Instance);\r
+    FreePool (Instance);\r
     return Status;\r
   }\r
 \r
@@ -668,6 +668,6 @@ Dhcp4ServiceBindingDestroyChild (
 \r
   gBS->RestoreTPL (OldTpl);\r
 \r
-  gBS->FreePool (Instance);\r
+  FreePool (Instance);\r
   return EFI_SUCCESS;\r
 }\r
index 6d82230457d8f06b604dc215ea9d9de7fffafb3b..90031903a45ab60b11bceaf6336cd7f4dbf51775 100644 (file)
@@ -427,21 +427,21 @@ DhcpCleanConfigure (
   UINT32                    Index;\r
 \r
   if (Config->DiscoverTimeout != NULL) {\r
-    gBS->FreePool (Config->DiscoverTimeout);\r
+    FreePool (Config->DiscoverTimeout);\r
   }\r
 \r
   if (Config->RequestTimeout != NULL) {\r
-    gBS->FreePool (Config->RequestTimeout);\r
+    FreePool (Config->RequestTimeout);\r
   }\r
 \r
   if (Config->OptionList != NULL) {\r
     for (Index = 0; Index < Config->OptionCount; Index++) {\r
       if (Config->OptionList[Index] != NULL) {\r
-        gBS->FreePool (Config->OptionList[Index]);\r
+        FreePool (Config->OptionList[Index]);\r
       }\r
     }\r
 \r
-    gBS->FreePool (Config->OptionList);\r
+    FreePool (Config->OptionList);\r
   }\r
 \r
   ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA));\r
@@ -564,14 +564,14 @@ DhcpYieldControl (
   DhcpSb->ActiveChild   = NULL;\r
 \r
   if (Config->DiscoverTimeout != NULL) {\r
-    gBS->FreePool (Config->DiscoverTimeout);\r
+    FreePool (Config->DiscoverTimeout);\r
 \r
     Config->DiscoverTryCount  = 0;\r
     Config->DiscoverTimeout   = NULL;\r
   }\r
 \r
   if (Config->RequestTimeout != NULL) {\r
-    gBS->FreePool (Config->RequestTimeout);\r
+    FreePool (Config->RequestTimeout);\r
 \r
     Config->RequestTryCount = 0;\r
     Config->RequestTimeout  = NULL;\r
index dc9b0412a834899a77ccc694cc11a11d3883281c..1b3afa3dd89df7cac6feacdfeb950a41cdc160fc 100644 (file)
@@ -446,17 +446,17 @@ DhcpCleanLease (
   DhcpSb->ServerAddr  = 0;\r
 \r
   if (DhcpSb->LastOffer != NULL) {\r
-    gBS->FreePool (DhcpSb->LastOffer);\r
+    FreePool (DhcpSb->LastOffer);\r
     DhcpSb->LastOffer = NULL;\r
   }\r
 \r
   if (DhcpSb->Selected != NULL) {\r
-    gBS->FreePool (DhcpSb->Selected);\r
+    FreePool (DhcpSb->Selected);\r
     DhcpSb->Selected = NULL;\r
   }\r
 \r
   if (DhcpSb->Para != NULL) {\r
-    gBS->FreePool (DhcpSb->Para);\r
+    FreePool (DhcpSb->Para);\r
     DhcpSb->Para = NULL;\r
   }\r
 \r
@@ -636,7 +636,7 @@ DhcpHandleSelect (
 \r
   if (Status == EFI_SUCCESS) {\r
     if (DhcpSb->LastOffer != NULL) {\r
-      gBS->FreePool (DhcpSb->LastOffer);\r
+      FreePool (DhcpSb->LastOffer);\r
     }\r
 \r
     DhcpSb->LastOffer = Packet;\r
@@ -645,7 +645,7 @@ DhcpHandleSelect (
 \r
   } else if (Status == EFI_NOT_READY) {\r
     if (DhcpSb->LastOffer != NULL) {\r
-      gBS->FreePool (DhcpSb->LastOffer);\r
+      FreePool (DhcpSb->LastOffer);\r
     }\r
 \r
     DhcpSb->LastOffer = Packet;\r
@@ -907,18 +907,14 @@ DhcpHandleReboot (
   //\r
   // OK, get the parameter from server, record the lease\r
   //\r
-  DhcpSb->Para = AllocatePool (sizeof (DHCP_PARAMETER));\r
-\r
+  DhcpSb->Para = AllocateCopyPool (sizeof (DHCP_PARAMETER), Para);\r
   if (DhcpSb->Para == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto ON_EXIT;\r
   }\r
 \r
   DhcpSb->Selected  = Packet;\r
-  CopyMem (DhcpSb->Para, Para, sizeof (*DhcpSb->Para));\r
-\r
   Status            = DhcpLeaseAcquired (DhcpSb);\r
-\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -1063,7 +1059,7 @@ DhcpInput (
   }\r
 \r
   if (Para != NULL) {\r
-    gBS->FreePool (Para);\r
+    FreePool (Para);\r
   }\r
 \r
   Packet = NULL;\r
index 559fd9ad0eca24addf62fac3165693d5f670ba37..8c4060517c1fab89f78e1e60052c001f0406b268 100644 (file)
@@ -604,7 +604,6 @@ DhcpParseOption (
   *OptionPoint  = NULL;\r
 \r
   if (OptNum == 0) {\r
-    Status = EFI_NOT_FOUND;\r
     goto ON_EXIT;\r
   }\r
 \r
@@ -626,14 +625,14 @@ DhcpParseOption (
   Status          = DhcpIterateOptions (Packet, DhcpFillOption, &Context);\r
 \r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (Options);\r
+    FreePool (Options);\r
     goto ON_EXIT;\r
   }\r
 \r
   *OptionPoint = Options;\r
 \r
 ON_EXIT:\r
-  gBS->FreePool (OptCount);\r
+  FreePool (OptCount);\r
   return Status;\r
 }\r
 \r
@@ -675,7 +674,8 @@ DhcpValidateOptions (
   if (EFI_ERROR (Status) || (Count == 0)) {\r
     return Status;\r
   }\r
-  \r
+  ASSERT (AllOption != NULL);\r
+\r
   Updated = FALSE;\r
   ZeroMem (&Parameter, sizeof (Parameter));\r
 \r
@@ -710,16 +710,15 @@ DhcpValidateOptions (
   }\r
 \r
   if (Updated && (Para != NULL)) {\r
-    if ((*Para = AllocatePool (sizeof (DHCP_PARAMETER))) == NULL) {\r
+    *Para = AllocateCopyPool (sizeof (DHCP_PARAMETER), &Parameter);\r
+    if (*Para == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_EXIT;\r
     }\r
-\r
-    CopyMem (*Para, &Parameter, sizeof (**Para));\r
   }\r
 \r
 ON_EXIT:\r
-  gBS->FreePool (AllOption);\r
+  FreePool (AllOption);\r
   return Status;\r
 }\r
 \r
@@ -825,10 +824,11 @@ DhcpBuild (
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
-  ASSERT (SeedOptions != NULL);\r
 \r
-  for (Index = 0; Index < (UINT32) Count; Index++) {\r
-    Mark[SeedOptions[Index].Tag] = SeedOptions[Index];\r
+  if (SeedOptions != NULL) {\r
+    for (Index = 0; Index < (UINT32) Count; Index++) {\r
+      Mark[SeedOptions[Index].Tag] = SeedOptions[Index];\r
+    }\r
   }\r
 \r
   //\r
@@ -888,9 +888,9 @@ DhcpBuild (
 \r
 ON_ERROR:\r
   if (SeedOptions != NULL) {\r
-    gBS->FreePool (SeedOptions);\r
+    FreePool (SeedOptions);\r
   }\r
 \r
-  gBS->FreePool (Mark);\r
+  FreePool (Mark);\r
   return Status;\r
 }\r
index a96303945a649507a17487342c59ff71c200cc87..57b1f7b5bc98c72dd35fa02aaa6b68a7459a2ffe 100644 (file)
@@ -962,11 +962,6 @@ MnpReceivePacket (
   //\r
   MnpDeliverPacket (MnpServiceData);\r
 \r
-  //\r
-  // Dispatch the DPC queued by the NotifyFunction of rx token's events.\r
-  //\r
-  NetLibDispatchDpc ();\r
-\r
 EXIT:\r
 \r
   ASSERT (Nbuf->TotalSize == MnpServiceData->BufferLength);\r
@@ -1066,5 +1061,8 @@ MnpSystemPoll (
   //\r
   MnpReceivePacket (MnpServiceData);\r
 \r
+  //\r
+  // Dispatch the DPC queued by the NotifyFunction of rx token's events.\r
+  //\r
   NetLibDispatchDpc ();\r
 }\r
index 1cbe4e4e6e8b1940f35d5671c738b2c9e51eceec..f93ee6ab77e80ad8e9720ef83f75e7d6057d661b 100644 (file)
@@ -771,6 +771,9 @@ MnpPoll (
   //\r
   Status = MnpReceivePacket (Instance->MnpServiceData);\r
 \r
+  //\r
+  // Dispatch the DPC queued by the NotifyFunction of rx token's events.\r
+  //\r
   NetLibDispatchDpc ();\r
 \r
 ON_EXIT:\r