]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Add more parameter or return status check in UDP6 driver
authorWang Fan <fan.wang@intel.com>
Wed, 3 Jan 2018 10:11:04 +0000 (18:11 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Thu, 11 Jan 2018 09:08:33 +0000 (17:08 +0800)
In UDP6Dxe, there are several places that may be enhanced
to check input parameters and returned status. This patch
is to fix these issues.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/Udp6Dxe/Udp6Driver.c
NetworkPkg/Udp6Dxe/Udp6Impl.c
NetworkPkg/Udp6Dxe/Udp6Main.c

index 6dde1fc07e96cd56598a87e5a2e9eff46441c72b..f9d528e68fb3cd623840d113a821e31453895d11 100644 (file)
@@ -290,18 +290,15 @@ Udp6DriverBindingStop (
                NULL\r
                );\r
   } else if (IsListEmpty (&Udp6Service->ChildrenList)) {\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           NicHandle,\r
-           &gEfiUdp6ServiceBindingProtocolGuid,\r
-           &Udp6Service->ServiceBinding,\r
-           NULL\r
-           );\r
+    Status = gBS->UninstallMultipleProtocolInterfaces (\r
+               NicHandle,\r
+               &gEfiUdp6ServiceBindingProtocolGuid,\r
+               &Udp6Service->ServiceBinding,\r
+               NULL\r
+               );\r
  \r
     Udp6CleanService (Udp6Service);\r
-\r
     FreePool (Udp6Service);\r
-\r
-    Status = EFI_SUCCESS;\r
   }\r
 \r
   return Status;\r
@@ -510,21 +507,30 @@ Udp6ServiceBindingDestroyChild (
   //\r
   // Close the Ip6 protocol on the default IpIo.\r
   //\r
-  gBS->CloseProtocol (\r
-         Udp6Service->IpIo->ChildHandle,\r
-         &gEfiIp6ProtocolGuid,\r
-         gUdp6DriverBinding.DriverBindingHandle,\r
-         Instance->ChildHandle\r
-         );\r
+  Status = gBS->CloseProtocol (\r
+             Udp6Service->IpIo->ChildHandle,\r
+             &gEfiIp6ProtocolGuid,\r
+             gUdp6DriverBinding.DriverBindingHandle,\r
+             Instance->ChildHandle\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    Instance->InDestroy = FALSE;\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Close the Ip6 protocol on this instance's IpInfo.\r
   //\r
-  gBS->CloseProtocol (\r
-         Instance->IpInfo->ChildHandle,\r
-         &gEfiIp6ProtocolGuid,\r
-         gUdp6DriverBinding.DriverBindingHandle,\r
-         Instance->ChildHandle\r
-         );\r
+  Status = gBS->CloseProtocol (\r
+             Instance->IpInfo->ChildHandle,\r
+             &gEfiIp6ProtocolGuid,\r
+             gUdp6DriverBinding.DriverBindingHandle,\r
+             Instance->ChildHandle\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    Instance->InDestroy = FALSE;\r
+    return Status;\r
+  }\r
 \r
   //\r
   // Uninstall the Udp6Protocol previously installed on the ChildHandle.\r
index 458470ce2c56d80d9432f7a0151e8e465f0c7191..d014e2dcbc88912638bbbd925ec0ba1a71aa0f63 100644 (file)
@@ -57,6 +57,9 @@ Udp6FindInstanceByPort (
   interface. It's called to signal the udp TxToken when the IpIo layer completes\r
   transmitting of the udp datagram.\r
 \r
+  If Context is NULL, then ASSERT().\r
+  If NotifyData is NULL, then ASSERT().\r
+\r
   @param[in]  Status            The completion status of the output udp datagram.\r
   @param[in]  Context           Pointer to the context data.\r
   @param[in]  Sender            Specify a EFI_IP6_PROTOCOL for sending.\r
@@ -75,6 +78,10 @@ Udp6DgramSent (
 /**\r
   This function processes the received datagram passed up by the IpIo layer.\r
 \r
+  If NetSession is NULL, then ASSERT().\r
+  If Packet is NULL, then ASSERT().\r
+  If Context is NULL, then ASSERT().\r
+\r
   @param[in]  Status            The status of this udp datagram.\r
   @param[in]  IcmpError         The IcmpError code, only available when Status is\r
                                 EFI_ICMP_ERROR.\r
@@ -977,6 +984,9 @@ Udp6RemoveToken (
   interface. It's called to signal the udp TxToken when IpIo layer completes the\r
   transmitting of the udp datagram.\r
 \r
+  If Context is NULL, then ASSERT().\r
+  If NotifyData is NULL, then ASSERT().\r
+\r
   @param[in]  Status            The completion status of the output udp datagram.\r
   @param[in]  Context           Pointer to the context data.\r
   @param[in]  Sender            Specify a EFI_IP6_PROTOCOL for sending.\r
@@ -995,6 +1005,8 @@ Udp6DgramSent (
   UDP6_INSTANCE_DATA         *Instance;\r
   EFI_UDP6_COMPLETION_TOKEN  *Token;\r
 \r
+  ASSERT (Context != NULL && NotifyData != NULL);\r
+\r
   Instance = (UDP6_INSTANCE_DATA *) Context;\r
   Token    = (EFI_UDP6_COMPLETION_TOKEN *) NotifyData;\r
 \r
@@ -1012,6 +1024,10 @@ Udp6DgramSent (
 /**\r
   This function processes the received datagram passed up by the IpIo layer.\r
 \r
+  If NetSession is NULL, then ASSERT().\r
+  If Packet is NULL, then ASSERT().\r
+  If Context is NULL, then ASSERT().\r
+\r
   @param[in]  Status            The status of this udp datagram.\r
   @param[in]  IcmpError         The IcmpError code, only available when Status is\r
                                 EFI_ICMP_ERROR.\r
@@ -1031,6 +1047,7 @@ Udp6DgramRcvd (
   IN VOID                  *Context\r
   )\r
 {\r
+  ASSERT (NetSession != NULL && Packet != NULL && Context != NULL);\r
   NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE);\r
 \r
   //\r
index 53145c38bebb433d84a2a46c0fb0cd2399f8759e..1d7f0acbc7dff48d9281ae8259a4c3712d941c0d 100644 (file)
@@ -381,7 +381,7 @@ Udp6Groups (
     Status = NetMapInsertTail (&Instance->McastIps, (VOID *) McastIp, NULL);\r
   } else {\r
 \r
-    NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, MulticastAddress);\r
+    Status = NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, MulticastAddress);\r
   }\r
 \r
 ON_EXIT:\r