Reviewed-by: Fu Siyuan <[email protected]>
> -----Original Message----- > From: Wu, Jiaxin > Sent: Tuesday, December 12, 2017 7:44 PM > To: [email protected] > Cc: Ye, Ting <[email protected]>; Fu, Siyuan <[email protected]>; Wang, > Fan <[email protected]>; Wu, Jiaxin <[email protected]> > Subject: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error > happen during Ip4StartAutoConfig(). > > Cc: Ye Ting <[email protected]> > Cc: Fu Siyuan <[email protected]> > Cc: Wang Fan <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wu Jiaxin <[email protected]> > --- > .../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 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

