diff options
author | Jiaxin Wu <jiaxin.wu@intel.com> | 2017-12-05 14:23:39 +0800 |
---|---|---|
committer | Jiaxin Wu <jiaxin.wu@intel.com> | 2017-12-13 16:25:40 +0800 |
commit | f3b108a8ef353d041771a5514ea48f5088083633 (patch) | |
tree | 01a33f11fee6b4a114053db42f962e6ef9b581f8 /MdeModulePkg | |
parent | 3fe97d9459f5235843e3570980ba7a189bafc812 (diff) | |
download | edk2-f3b108a8ef353d041771a5514ea48f5088083633.zip edk2-f3b108a8ef353d041771a5514ea48f5088083633.tar.gz edk2-f3b108a8ef353d041771a5514ea48f5088083633.tar.bz2 |
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>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 46 |
1 files 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 @@ -917,7 +917,6 @@ Ip4StartAutoConfig ( IP4_CONFIG2_DHCP4_OPTION ParaList;
EFI_STATUS Status;
-
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
if (IpSb->State > IP4_SERVICE_UNSTARTED) {
@@ -970,8 +969,18 @@ Ip4StartAutoConfig ( 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
@@ -979,11 +988,10 @@ Ip4StartAutoConfig ( //
Dhcp4 = Instance->Dhcp4;
Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
-
if (Dhcp4Mode.State == Dhcp4Bound) {
Ip4Config2OnDhcp4Complete (NULL, Instance);
+
return EFI_SUCCESS;
-
}
//
@@ -1001,8 +1009,25 @@ Ip4StartAutoConfig ( 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;
}
@@ -1016,21 +1041,24 @@ Ip4StartAutoConfig ( 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;
-
}
|