* [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
@ 2017-12-12 11:44 Jiaxin Wu
2017-12-13 1:24 ` Fu, Siyuan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jiaxin Wu @ 2017-12-12 11:44 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wang Fan, Wu Jiaxin
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
.../Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 46 +++++++++++++++++-----
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 26530e3..f2640b7 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -915,11 +915,10 @@ Ip4StartAutoConfig (
EFI_DHCP4_MODE_DATA Dhcp4Mode;
EFI_DHCP4_PACKET_OPTION *OptionList[1];
IP4_CONFIG2_DHCP4_OPTION ParaList;
EFI_STATUS Status;
-
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
if (IpSb->State > IP4_SERVICE_UNSTARTED) {
return EFI_SUCCESS;
}
@@ -968,24 +967,33 @@ Ip4StartAutoConfig (
(VOID **) &Instance->Dhcp4,
IpSb->Image,
IpSb->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ NetLibDestroyServiceChild (
+ IpSb->Controller,
+ IpSb->Image,
+ &gEfiDhcp4ServiceBindingProtocolGuid,
+ Instance->Dhcp4Handle
+ );
+ Instance->Dhcp4Handle = NULL;
+
+ return Status;
+ }
//
// Check the current DHCP status, if the DHCP process has
// already finished, return now.
//
Dhcp4 = Instance->Dhcp4;
Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
-
if (Dhcp4Mode.State == Dhcp4Bound) {
Ip4Config2OnDhcp4Complete (NULL, Instance);
+
return EFI_SUCCESS;
-
}
//
// Try to start the DHCP process. Use most of the current
// DHCP configuration to avoid problems if some DHCP client
@@ -999,12 +1007,29 @@ Ip4StartAutoConfig (
OptionList[0] = &ParaList.Head;
Dhcp4Mode.ConfigData.OptionCount = 1;
Dhcp4Mode.ConfigData.OptionList = OptionList;
Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData);
-
if (EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Instance->Dhcp4Handle,
+ &gEfiDhcp4ProtocolGuid,
+ IpSb->Image,
+ IpSb->Controller
+ );
+
+ NetLibDestroyServiceChild (
+ IpSb->Controller,
+ IpSb->Image,
+ &gEfiDhcp4ServiceBindingProtocolGuid,
+ Instance->Dhcp4Handle
+ );
+
+ Instance->Dhcp4 = NULL;
+
+ Instance->Dhcp4Handle = NULL;
+
return Status;
}
//
// Start the DHCP process
@@ -1014,25 +1039,28 @@ Ip4StartAutoConfig (
TPL_CALLBACK,
Ip4Config2OnDhcp4Complete,
Instance,
&Instance->Dhcp4Event
);
-
if (EFI_ERROR (Status)) {
+ Ip4Config2DestroyDhcp4 (Instance);
return Status;
}
Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event);
-
if (EFI_ERROR (Status)) {
+ Ip4Config2DestroyDhcp4 (Instance);
+ gBS->CloseEvent (Instance->Dhcp4Event);
+ Instance->Dhcp4Event = NULL;
+
return Status;
}
- IpSb->State = IP4_SERVICE_STARTED;
+ IpSb->State = IP4_SERVICE_STARTED;
DispatchDpc ();
+
return EFI_SUCCESS;
-
}
/**
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
2017-12-12 11:44 [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig() Jiaxin Wu
@ 2017-12-13 1:24 ` Fu, Siyuan
2017-12-13 1:39 ` Fu, Siyuan
2017-12-13 3:20 ` Ye, Ting
2 siblings, 0 replies; 4+ messages in thread
From: Fu, Siyuan @ 2017-12-13 1:24 UTC (permalink / raw)
To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wang, Fan
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Tuesday, December 12, 2017 7:44 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wang,
> Fan <fan.wang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error
> happen during Ip4StartAutoConfig().
>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wang Fan <fan.wang@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
> .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 46
> +++++++++++++++++-----
> 1 file changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> index 26530e3..f2640b7 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> @@ -915,11 +915,10 @@ Ip4StartAutoConfig (
> EFI_DHCP4_MODE_DATA Dhcp4Mode;
> EFI_DHCP4_PACKET_OPTION *OptionList[1];
> IP4_CONFIG2_DHCP4_OPTION ParaList;
> EFI_STATUS Status;
>
> -
> IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
>
> if (IpSb->State > IP4_SERVICE_UNSTARTED) {
> return EFI_SUCCESS;
> }
> @@ -968,24 +967,33 @@ Ip4StartAutoConfig (
> (VOID **) &Instance->Dhcp4,
> IpSb->Image,
> IpSb->Controller,
> EFI_OPEN_PROTOCOL_BY_DRIVER
> );
> - ASSERT_EFI_ERROR (Status);
> + if (EFI_ERROR (Status)) {
> + NetLibDestroyServiceChild (
> + IpSb->Controller,
> + IpSb->Image,
> + &gEfiDhcp4ServiceBindingProtocolGuid,
> + Instance->Dhcp4Handle
> + );
>
> + Instance->Dhcp4Handle = NULL;
> +
> + return Status;
> + }
>
> //
> // Check the current DHCP status, if the DHCP process has
> // already finished, return now.
> //
> Dhcp4 = Instance->Dhcp4;
> Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
> -
> if (Dhcp4Mode.State == Dhcp4Bound) {
> Ip4Config2OnDhcp4Complete (NULL, Instance);
> +
> return EFI_SUCCESS;
> -
> }
>
> //
> // Try to start the DHCP process. Use most of the current
> // DHCP configuration to avoid problems if some DHCP client
> @@ -999,12 +1007,29 @@ Ip4StartAutoConfig (
> OptionList[0] = &ParaList.Head;
> Dhcp4Mode.ConfigData.OptionCount = 1;
> Dhcp4Mode.ConfigData.OptionList = OptionList;
>
> Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData);
> -
> if (EFI_ERROR (Status)) {
> + gBS->CloseProtocol (
> + Instance->Dhcp4Handle,
> + &gEfiDhcp4ProtocolGuid,
> + IpSb->Image,
> + IpSb->Controller
> + );
> +
> + NetLibDestroyServiceChild (
> + IpSb->Controller,
> + IpSb->Image,
> + &gEfiDhcp4ServiceBindingProtocolGuid,
> + Instance->Dhcp4Handle
> + );
> +
> + Instance->Dhcp4 = NULL;
> +
> + Instance->Dhcp4Handle = NULL;
> +
> return Status;
> }
>
> //
> // Start the DHCP process
> @@ -1014,25 +1039,28 @@ Ip4StartAutoConfig (
> TPL_CALLBACK,
> Ip4Config2OnDhcp4Complete,
> Instance,
> &Instance->Dhcp4Event
> );
> -
> if (EFI_ERROR (Status)) {
> + Ip4Config2DestroyDhcp4 (Instance);
> return Status;
> }
>
> Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event);
> -
> if (EFI_ERROR (Status)) {
> + Ip4Config2DestroyDhcp4 (Instance);
> + gBS->CloseEvent (Instance->Dhcp4Event);
> + Instance->Dhcp4Event = NULL;
> +
> return Status;
> }
>
> - IpSb->State = IP4_SERVICE_STARTED;
> + IpSb->State = IP4_SERVICE_STARTED;
> DispatchDpc ();
> +
> return EFI_SUCCESS;
> -
> }
>
>
>
> /**
> --
> 1.9.5.msysgit.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
2017-12-12 11:44 [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig() Jiaxin Wu
2017-12-13 1:24 ` Fu, Siyuan
@ 2017-12-13 1:39 ` Fu, Siyuan
2017-12-13 3:20 ` Ye, Ting
2 siblings, 0 replies; 4+ messages in thread
From: Fu, Siyuan @ 2017-12-13 1:39 UTC (permalink / raw)
To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wang, Fan
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Tuesday, December 12, 2017 7:44 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wang,
> Fan <fan.wang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error
> happen during Ip4StartAutoConfig().
>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wang Fan <fan.wang@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
> .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 46
> +++++++++++++++++-----
> 1 file changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> index 26530e3..f2640b7 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> @@ -915,11 +915,10 @@ Ip4StartAutoConfig (
> EFI_DHCP4_MODE_DATA Dhcp4Mode;
> EFI_DHCP4_PACKET_OPTION *OptionList[1];
> IP4_CONFIG2_DHCP4_OPTION ParaList;
> EFI_STATUS Status;
>
> -
> IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
>
> if (IpSb->State > IP4_SERVICE_UNSTARTED) {
> return EFI_SUCCESS;
> }
> @@ -968,24 +967,33 @@ Ip4StartAutoConfig (
> (VOID **) &Instance->Dhcp4,
> IpSb->Image,
> IpSb->Controller,
> EFI_OPEN_PROTOCOL_BY_DRIVER
> );
> - ASSERT_EFI_ERROR (Status);
> + if (EFI_ERROR (Status)) {
> + NetLibDestroyServiceChild (
> + IpSb->Controller,
> + IpSb->Image,
> + &gEfiDhcp4ServiceBindingProtocolGuid,
> + Instance->Dhcp4Handle
> + );
>
> + Instance->Dhcp4Handle = NULL;
> +
> + return Status;
> + }
>
> //
> // Check the current DHCP status, if the DHCP process has
> // already finished, return now.
> //
> Dhcp4 = Instance->Dhcp4;
> Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
> -
> if (Dhcp4Mode.State == Dhcp4Bound) {
> Ip4Config2OnDhcp4Complete (NULL, Instance);
> +
> return EFI_SUCCESS;
> -
> }
>
> //
> // Try to start the DHCP process. Use most of the current
> // DHCP configuration to avoid problems if some DHCP client
> @@ -999,12 +1007,29 @@ Ip4StartAutoConfig (
> OptionList[0] = &ParaList.Head;
> Dhcp4Mode.ConfigData.OptionCount = 1;
> Dhcp4Mode.ConfigData.OptionList = OptionList;
>
> Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData);
> -
> if (EFI_ERROR (Status)) {
> + gBS->CloseProtocol (
> + Instance->Dhcp4Handle,
> + &gEfiDhcp4ProtocolGuid,
> + IpSb->Image,
> + IpSb->Controller
> + );
> +
> + NetLibDestroyServiceChild (
> + IpSb->Controller,
> + IpSb->Image,
> + &gEfiDhcp4ServiceBindingProtocolGuid,
> + Instance->Dhcp4Handle
> + );
> +
> + Instance->Dhcp4 = NULL;
> +
> + Instance->Dhcp4Handle = NULL;
> +
> return Status;
> }
>
> //
> // Start the DHCP process
> @@ -1014,25 +1039,28 @@ Ip4StartAutoConfig (
> TPL_CALLBACK,
> Ip4Config2OnDhcp4Complete,
> Instance,
> &Instance->Dhcp4Event
> );
> -
> if (EFI_ERROR (Status)) {
> + Ip4Config2DestroyDhcp4 (Instance);
> return Status;
> }
>
> Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event);
> -
> if (EFI_ERROR (Status)) {
> + Ip4Config2DestroyDhcp4 (Instance);
> + gBS->CloseEvent (Instance->Dhcp4Event);
> + Instance->Dhcp4Event = NULL;
> +
> return Status;
> }
>
> - IpSb->State = IP4_SERVICE_STARTED;
> + IpSb->State = IP4_SERVICE_STARTED;
> DispatchDpc ();
> +
> return EFI_SUCCESS;
> -
> }
>
>
>
> /**
> --
> 1.9.5.msysgit.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
2017-12-12 11:44 [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig() Jiaxin Wu
2017-12-13 1:24 ` Fu, Siyuan
2017-12-13 1:39 ` Fu, Siyuan
@ 2017-12-13 3:20 ` Ye, Ting
2 siblings, 0 replies; 4+ messages in thread
From: Ye, Ting @ 2017-12-13 3:20 UTC (permalink / raw)
To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Fu, Siyuan, Wang, Fan
Reviewed-by: Ye Ting <ting.ye@intel.com>
-----Original Message-----
From: Wu, Jiaxin
Sent: Tuesday, December 12, 2017 7:44 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wang, Fan <fan.wang@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
.../Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 46 +++++++++++++++++-----
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 26530e3..f2640b7 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -915,11 +915,10 @@ Ip4StartAutoConfig (
EFI_DHCP4_MODE_DATA Dhcp4Mode;
EFI_DHCP4_PACKET_OPTION *OptionList[1];
IP4_CONFIG2_DHCP4_OPTION ParaList;
EFI_STATUS Status;
-
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
if (IpSb->State > IP4_SERVICE_UNSTARTED) {
return EFI_SUCCESS;
}
@@ -968,24 +967,33 @@ Ip4StartAutoConfig (
(VOID **) &Instance->Dhcp4,
IpSb->Image,
IpSb->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ NetLibDestroyServiceChild (
+ IpSb->Controller,
+ IpSb->Image,
+ &gEfiDhcp4ServiceBindingProtocolGuid,
+ Instance->Dhcp4Handle
+ );
+ Instance->Dhcp4Handle = NULL;
+
+ return Status;
+ }
//
// Check the current DHCP status, if the DHCP process has
// already finished, return now.
//
Dhcp4 = Instance->Dhcp4;
Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
-
if (Dhcp4Mode.State == Dhcp4Bound) {
Ip4Config2OnDhcp4Complete (NULL, Instance);
+
return EFI_SUCCESS;
-
}
//
// Try to start the DHCP process. Use most of the current
// DHCP configuration to avoid problems if some DHCP client @@ -999,12 +1007,29 @@ Ip4StartAutoConfig (
OptionList[0] = &ParaList.Head;
Dhcp4Mode.ConfigData.OptionCount = 1;
Dhcp4Mode.ConfigData.OptionList = OptionList;
Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData);
-
if (EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Instance->Dhcp4Handle,
+ &gEfiDhcp4ProtocolGuid,
+ IpSb->Image,
+ IpSb->Controller
+ );
+
+ NetLibDestroyServiceChild (
+ IpSb->Controller,
+ IpSb->Image,
+ &gEfiDhcp4ServiceBindingProtocolGuid,
+ Instance->Dhcp4Handle
+ );
+
+ Instance->Dhcp4 = NULL;
+
+ Instance->Dhcp4Handle = NULL;
+
return Status;
}
//
// Start the DHCP process
@@ -1014,25 +1039,28 @@ Ip4StartAutoConfig (
TPL_CALLBACK,
Ip4Config2OnDhcp4Complete,
Instance,
&Instance->Dhcp4Event
);
-
if (EFI_ERROR (Status)) {
+ Ip4Config2DestroyDhcp4 (Instance);
return Status;
}
Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event);
-
if (EFI_ERROR (Status)) {
+ Ip4Config2DestroyDhcp4 (Instance);
+ gBS->CloseEvent (Instance->Dhcp4Event);
+ Instance->Dhcp4Event = NULL;
+
return Status;
}
- IpSb->State = IP4_SERVICE_STARTED;
+ IpSb->State = IP4_SERVICE_STARTED;
DispatchDpc ();
+
return EFI_SUCCESS;
-
}
/**
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-13 3:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-12 11:44 [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig() Jiaxin Wu
2017-12-13 1:24 ` Fu, Siyuan
2017-12-13 1:39 ` Fu, Siyuan
2017-12-13 3:20 ` Ye, Ting
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox