There may be an error happens when we use the
configure function to set or change the configuration
data for the DNS6 instance, So we will free the
DnsServerList without configured to NULL. If we reset
the instance with the parameter DnsConfigData to NULL, the
DnsServerList will be freed twice.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zh...@intel.com>
Cc: Ye Ting <ting...@intel.com>
Cc: Fu Siyuan <siyuan...@intel.com>
Cc: Wu Jiaxin <jiaxin...@intel.com>
---
 NetworkPkg/DnsDxe/DnsProtocol.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c
index 64fca6a..6d117b2 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -285,10 +285,11 @@ Dns4Configure (
     //
     Status = Dns4ConfigUdp (Instance, Instance->UdpIo);
     if (EFI_ERROR (Status)) {
       if (Instance->Dns4CfgData.DnsServerList != NULL) {
         FreePool (Instance->Dns4CfgData.DnsServerList);
+        Instance->Dns4CfgData.DnsServerList = NULL;
       }
       goto ON_EXIT;
     }
 
     //
@@ -296,10 +297,11 @@ Dns4Configure (
     //
     Status = AddDns4ServerIp (&mDriverData->Dns4ServerList, 
Instance->SessionDnsServer.v4);
     if (EFI_ERROR (Status)) {
       if (Instance->Dns4CfgData.DnsServerList != NULL) {
         FreePool (Instance->Dns4CfgData.DnsServerList);
+        Instance->Dns4CfgData.DnsServerList = NULL;
       }
       goto ON_EXIT;
     }
     
     Instance->State = DNS_STATE_CONFIGED;
@@ -1106,10 +1108,11 @@ Dns6Configure (
     //
     Status = Dns6ConfigUdp (Instance, Instance->UdpIo);
     if (EFI_ERROR (Status)) {
       if (Instance->Dns6CfgData.DnsServerList != NULL) {
         FreePool (Instance->Dns6CfgData.DnsServerList);
+        Instance->Dns6CfgData.DnsServerList = NULL;
       }
       goto ON_EXIT;
     }
 
     //
@@ -1117,10 +1120,11 @@ Dns6Configure (
     //
     Status = AddDns6ServerIp (&mDriverData->Dns6ServerList, 
Instance->SessionDnsServer.v6);
     if (EFI_ERROR (Status)) {
       if (Instance->Dns6CfgData.DnsServerList != NULL) {
         FreePool (Instance->Dns6CfgData.DnsServerList);
+        Instance->Dns6CfgData.DnsServerList = NULL;
       }
       goto ON_EXIT;
     }
     
     Instance->State = DNS_STATE_CONFIGED;
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to