From: "Fu, Siyuan" <siyuan.fu@intel.com>
To: "Wu, Jiaxin" <jiaxin.wu@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ye, Ting" <ting.ye@intel.com>, "Wang, Fan" <fan.wang@intel.com>
Subject: Re: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
Date: Wed, 13 Dec 2017 01:39:15 +0000 [thread overview]
Message-ID: <B1FF2E9001CE9041BD10B825821D5BC58B3F3F7E@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1513079049-8108-1-git-send-email-jiaxin.wu@intel.com>
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
next prev parent reply other threads:[~2017-12-13 1:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2017-12-13 3:20 ` Ye, Ting
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B1FF2E9001CE9041BD10B825821D5BC58B3F3F7E@SHSMSX103.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox