]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Fix IPv4 double free
authorSamer El-Haj-Mahmoud <elhaj@hpe.com>
Fri, 4 Mar 2016 07:18:49 +0000 (15:18 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Fri, 4 Mar 2016 07:20:58 +0000 (15:20 +0800)
Fix a possible ASSERT after NBP finishes loading from a PXE
boot. Ip4Dxe driver calls Ip4Config2SetPolicy which calls
CloseEvent on the Dhcp4Event struct member.  After NBP is
downloaded, it then calls Ip4Config2CleanInstance which calls
CloseEvent again on Dhcp4Event.  This double free can cause an
ASSERT. When the event is closed, set the event pointer to NULL
so the Ip4 code won't call CloseEvent on it again.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c

index 1f763b6bfe0df8a62f91ffd7bcac2c376a552a76..17e0247832200cbf3fe7504ab762544cff18b5d4 100644 (file)
@@ -2,7 +2,7 @@
   The implementation of EFI IPv4 Configuration II Protocol.\r
 \r
   Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<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
@@ -1194,6 +1194,7 @@ Ip4Config2SetPolicy (
       //\r
       if (Instance->Dhcp4Event != NULL) {\r
         gBS->CloseEvent (Instance->Dhcp4Event);\r
+        Instance->Dhcp4Event = NULL;\r
       }\r
     }\r
   }\r
@@ -1997,6 +1998,7 @@ Ip4Config2CleanInstance (
   //\r
   if (Instance->Dhcp4Event != NULL) {\r
     gBS->CloseEvent (Instance->Dhcp4Event);\r
+    Instance->Dhcp4Event = NULL;\r
   }\r
 \r
   for (Index = 0; Index < Ip4Config2DataTypeMaximum; Index++) {\r