summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/IpSecDxe/IpSecImpl.c
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2016-06-17 11:59:47 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2016-06-21 12:56:24 +0800
commit6b16c9e7eaf0059352d39b64ffa542e38b1e8dcf (patch)
tree05837ee51d7225000b188fcead20e747765a4707 /NetworkPkg/IpSecDxe/IpSecImpl.c
parent415aa2f1cb915a00b2d91fdfb1798bb75bcaed09 (diff)
downloadedk2-6b16c9e7eaf0059352d39b64ffa542e38b1e8dcf.tar.gz
edk2-6b16c9e7eaf0059352d39b64ffa542e38b1e8dcf.tar.bz2
edk2-6b16c9e7eaf0059352d39b64ffa542e38b1e8dcf.zip
NetworkPkg: Remove ASSERT and use error handling in IpSecDxe
This patch is used to refine the code by removing ASSERT and using error handling in IpSecDxe driver. Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Zhang Lubo <lubo.zhang@intel.com> Cc: Yao Jiewen <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
Diffstat (limited to 'NetworkPkg/IpSecDxe/IpSecImpl.c')
-rw-r--r--NetworkPkg/IpSecDxe/IpSecImpl.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/NetworkPkg/IpSecDxe/IpSecImpl.c b/NetworkPkg/IpSecDxe/IpSecImpl.c
index 854a9a58d8..625f154ff4 100644
--- a/NetworkPkg/IpSecDxe/IpSecImpl.c
+++ b/NetworkPkg/IpSecDxe/IpSecImpl.c
@@ -2,7 +2,7 @@
The implementation of IPsec.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1190,9 +1190,6 @@ IpSecTunnelInboundPacket (
on return.
@param[in] FragmentCount The number of fragments.
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES The required system resources can't be allocated.
-
**/
UINT8 *
IpSecTunnelOutboundPacket (
@@ -1220,7 +1217,10 @@ IpSecTunnelOutboundPacket (
if (IpVersion == IP_VERSION_4) {
InnerHead = AllocateZeroPool (sizeof (IP4_HEAD) + *OptionsLength);
- ASSERT (InnerHead != NULL);
+ if (InnerHead == NULL) {
+ return NULL;
+ }
+
CopyMem (
InnerHead,
IpHead,
@@ -1233,7 +1233,10 @@ IpSecTunnelOutboundPacket (
);
} else {
InnerHead = AllocateZeroPool (sizeof (EFI_IP6_HEADER) + *OptionsLength);
- ASSERT (InnerHead != NULL);
+ if (InnerHead == NULL) {
+ return NULL;
+ }
+
CopyMem (
InnerHead,
IpHead,
@@ -1264,7 +1267,11 @@ IpSecTunnelOutboundPacket (
IpSecOnRecyclePacket,
NULL
);
- ASSERT (Packet != NULL);
+ if (Packet == NULL) {
+ FreePool (InnerHead);
+ return NULL;
+ }
+
//
// 3. Check the Last Header, if it is TCP, UDP or ICMP recalcualate its pesudo
// CheckSum.