From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4BBF02214E320 for ; Tue, 12 Dec 2017 17:23:42 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 17:28:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,395,1508828400"; d="scan'208";a="2259563" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 12 Dec 2017 17:28:19 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Dec 2017 17:27:15 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Wed, 13 Dec 2017 09:24:19 +0800 From: "Fu, Siyuan" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Wang, Fan" Thread-Topic: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig(). Thread-Index: AQHTcz6Kw4e18gcBz06ihre8P4CECqNAe62g Date: Wed, 13 Dec 2017 01:24:19 +0000 Message-ID: References: <1513079049-8108-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1513079049-8108-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjU0NWJkODEtNGJiMC00NDkzLWIyNjgtZDRjZTUyNTYxYzU2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJPRUU0WEdkS1ZIcThKRHAwT3NqQ1Q2NmtMc09qczJ0N3lHUWFIenViNmlYUTRzRFhjOXFqeENqXC9NaHFiaE91bSJ9 dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig(). X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2017 01:23:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan > -----Original Message----- > From: Wu, Jiaxin > Sent: Tuesday, December 12, 2017 7:44 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Fu, Siyuan ; Wang, > Fan ; Wu, Jiaxin > Subject: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error > happen during Ip4StartAutoConfig(). >=20 > Cc: Ye Ting > Cc: Fu Siyuan > Cc: Wang Fan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wu Jiaxin > --- > .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 46 > +++++++++++++++++----- > 1 file changed, 37 insertions(+), 9 deletions(-) >=20 > 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; >=20 > - > IpSb =3D IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); >=20 > 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 > + ); >=20 > + Instance->Dhcp4Handle =3D NULL; > + > + return Status; > + } >=20 > // > // Check the current DHCP status, if the DHCP process has > // already finished, return now. > // > Dhcp4 =3D Instance->Dhcp4; > Status =3D Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode); > - > if (Dhcp4Mode.State =3D=3D Dhcp4Bound) { > Ip4Config2OnDhcp4Complete (NULL, Instance); > + > return EFI_SUCCESS; > - > } >=20 > // > // 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] =3D &ParaList.Head; > Dhcp4Mode.ConfigData.OptionCount =3D 1; > Dhcp4Mode.ConfigData.OptionList =3D OptionList; >=20 > Status =3D 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 =3D NULL; > + > + Instance->Dhcp4Handle =3D NULL; > + > return Status; > } >=20 > // > // Start the DHCP process > @@ -1014,25 +1039,28 @@ Ip4StartAutoConfig ( > TPL_CALLBACK, > Ip4Config2OnDhcp4Complete, > Instance, > &Instance->Dhcp4Event > ); > - > if (EFI_ERROR (Status)) { > + Ip4Config2DestroyDhcp4 (Instance); > return Status; > } >=20 > Status =3D Dhcp4->Start (Dhcp4, Instance->Dhcp4Event); > - > if (EFI_ERROR (Status)) { > + Ip4Config2DestroyDhcp4 (Instance); > + gBS->CloseEvent (Instance->Dhcp4Event); > + Instance->Dhcp4Event =3D NULL; > + > return Status; > } >=20 > - IpSb->State =3D IP4_SERVICE_STARTED; > + IpSb->State =3D IP4_SERVICE_STARTED; > DispatchDpc (); > + > return EFI_SUCCESS; > - > } >=20 >=20 >=20 > /** > -- > 1.9.5.msysgit.1