]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IpSecDxe/IpSecImpl.c
NetworkPkg: Remove ASSERT and use error handling in IpSecDxe
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IpSecImpl.c
index 854a9a58d8bf95e0467f229b8df8712ed1629d4f..625f154ff4104aa7a9a352a06792bcbd25ae780f 100644 (file)
@@ -2,7 +2,7 @@
   The implementation of IPsec.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1190,9 +1190,6 @@ IpSecTunnelInboundPacket (
                                      on return.\r
   @param[in]      FragmentCount      The number of fragments.\r
 \r
-  @retval EFI_SUCCESS              The operation was successful.\r
-  @retval EFI_OUT_OF_RESOURCES     The required system resources can't be allocated.\r
-\r
 **/\r
 UINT8 *\r
 IpSecTunnelOutboundPacket (\r
@@ -1220,7 +1217,10 @@ IpSecTunnelOutboundPacket (
 \r
   if (IpVersion == IP_VERSION_4) {\r
     InnerHead = AllocateZeroPool (sizeof (IP4_HEAD) + *OptionsLength);\r
-    ASSERT (InnerHead != NULL);\r
+    if (InnerHead == NULL) {\r
+      return NULL;\r
+    }\r
+    \r
     CopyMem (\r
       InnerHead,\r
       IpHead,\r
@@ -1233,7 +1233,10 @@ IpSecTunnelOutboundPacket (
       );\r
   } else {\r
     InnerHead = AllocateZeroPool (sizeof (EFI_IP6_HEADER) + *OptionsLength);\r
-    ASSERT (InnerHead != NULL);\r
+    if (InnerHead == NULL) {\r
+      return NULL;\r
+    }\r
+    \r
     CopyMem (\r
       InnerHead,\r
       IpHead,\r
@@ -1264,7 +1267,11 @@ IpSecTunnelOutboundPacket (
              IpSecOnRecyclePacket,\r
              NULL\r
              );\r
-  ASSERT (Packet != NULL);\r
+  if (Packet == NULL) {\r
+    FreePool (InnerHead);\r
+    return NULL;\r
+  }\r
+  \r
   //\r
   // 3. Check the Last Header, if it is TCP, UDP or ICMP recalcualate its pesudo\r
   //    CheckSum.\r