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=192.55.52.136; helo=mga12.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 3E89A2214E320 for ; Tue, 12 Dec 2017 17:34:40 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 17:39:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,395,1508828400"; d="scan'208";a="17752637" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 12 Dec 2017 17:39:18 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Dec 2017 17:39:17 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Dec 2017 17:39:16 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.175]) with mapi id 14.03.0319.002; Wed, 13 Dec 2017 09:39:15 +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: AQHTcz6KYEAR5HFpSEObOS3LxOJG16NAf9kQ Date: Wed, 13 Dec 2017 01:39:15 +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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWU2MWI4MGMtMjMyZi00OGE4LWFiOWMtM2ViOTkyMGNkNjI1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiIreGp1dEtvNGh4OHZLNzhRNE16UnJCNHhjTmVQZldXSmNFaGxaXC9HWmRXaDIyOTZSUmxiMDlJbXc3VThSdGNqUSJ9 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:34:40 -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