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.20; helo=mga02.intel.com; envelope-from=ting.ye@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 46E542214E32D for ; Tue, 12 Dec 2017 19:15:46 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 19:20:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,396,1508828400"; d="scan'208";a="11395895" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 12 Dec 2017 19:20:24 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Dec 2017 19:20:24 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Dec 2017 19:20:23 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Wed, 13 Dec 2017 11:20:21 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Wang, Fan" Thread-Topic: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig(). Thread-Index: AQHTcz6Kvb8sajzfZES3CYmWRwMOM6NAnA/w Date: Wed, 13 Dec 2017 03:20:21 +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: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 03:15:46 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting =20 -----Original Message----- From: Wu, Jiaxin=20 Sent: Tuesday, December 12, 2017 7:44 PM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Fu, Siyuan ; Wang, F= an ; Wu, Jiaxin Subject: [Patch] MdeModulePkg/Ip4Dxe: Cleanup the resource after error happ= en during Ip4StartAutoConfig(). 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(-) diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeMo= dulePkg/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; + =20 + 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); + =20 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 + ); + =20 + Instance->Dhcp4 =3D NULL; + =20 + Instance->Dhcp4Handle =3D NULL; + =20 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; + =20 return Status; } =20 - IpSb->State =3D IP4_SERVICE_STARTED; + IpSb->State =3D IP4_SERVICE_STARTED; DispatchDpc (); + =20 return EFI_SUCCESS; - } =20 =20 =20 /** -- 1.9.5.msysgit.1