From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 595191A1EC4 for ; Fri, 14 Oct 2016 05:12:10 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E40B23D94C; Fri, 14 Oct 2016 12:12:09 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-51.phx2.redhat.com [10.3.116.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9ECC8Ek015099; Fri, 14 Oct 2016 08:12:08 -0400 To: Zhang Lubo , edk2-devel@ml01.01.org References: <1476428061-23960-1-git-send-email-lubo.zhang@intel.com> Cc: Ye Ting , Fu Siyuan , Wu Jiaxin From: Laszlo Ersek Message-ID: <3b947323-e3b0-9a52-525b-957a0cad7e0e@redhat.com> Date: Fri, 14 Oct 2016 14:12:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1476428061-23960-1-git-send-email-lubo.zhang@intel.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 14 Oct 2016 12:12:09 +0000 (UTC) Subject: Re: [patch] NetworkPkg: Enhance the code in DNS driver. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 12:12:10 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 10/14/16 08:54, Zhang Lubo wrote: > 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 > Cc: Ye Ting > Cc: Fu Siyuan > Cc: Wu Jiaxin > --- > NetworkPkg/DnsDxe/DnsProtocol.c | 4 ++++ > 1 file changed, 4 insertions(+) The subject line of the patch is near useless, I'm afraid. How about: NetworkPkg/DnsDxe: eliminate double-free on DNS configuration failure Thanks Laszlo > 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; >