* [patch] NetworkPkg: Enhance the code in DNS driver.
@ 2016-10-14 6:54 Zhang Lubo
2016-10-14 12:12 ` Laszlo Ersek
2016-10-17 9:06 ` Fu, Siyuan
0 siblings, 2 replies; 3+ messages in thread
From: Zhang Lubo @ 2016-10-14 6:54 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin
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.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] NetworkPkg: Enhance the code in DNS driver.
2016-10-14 6:54 [patch] NetworkPkg: Enhance the code in DNS driver Zhang Lubo
@ 2016-10-14 12:12 ` Laszlo Ersek
2016-10-17 9:06 ` Fu, Siyuan
1 sibling, 0 replies; 3+ messages in thread
From: Laszlo Ersek @ 2016-10-14 12:12 UTC (permalink / raw)
To: Zhang Lubo, edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin
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 <lubo.zhang@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
> 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;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] NetworkPkg: Enhance the code in DNS driver.
2016-10-14 6:54 [patch] NetworkPkg: Enhance the code in DNS driver Zhang Lubo
2016-10-14 12:12 ` Laszlo Ersek
@ 2016-10-17 9:06 ` Fu, Siyuan
1 sibling, 0 replies; 3+ messages in thread
From: Fu, Siyuan @ 2016-10-17 9:06 UTC (permalink / raw)
To: Zhang, Lubo, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wu, Jiaxin
Reviewed-by: Fu Siyuan siyuan.fu@intel.com
> -----Original Message-----
> From: Zhang, Lubo
> Sent: Friday, October 14, 2016 2:54 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [patch] NetworkPkg: Enhance the code in DNS driver.
>
> 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.zhang@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-17 9:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-14 6:54 [patch] NetworkPkg: Enhance the code in DNS driver Zhang Lubo
2016-10-14 12:12 ` Laszlo Ersek
2016-10-17 9:06 ` Fu, Siyuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox