From nobody Mon May 6 15:56:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1513079055898422.77510633364534; Tue, 12 Dec 2017 03:44:15 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B7074220EE10E; Tue, 12 Dec 2017 03:39:35 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 3F65A21A1099A for ; Tue, 12 Dec 2017 03:39:33 -0800 (PST) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 03:44:12 -0800 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.254.209.49]) by orsmga007.jf.intel.com with ESMTP; 12 Dec 2017 03:44:10 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,395,1508828400"; d="scan'208";a="2085556" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 12 Dec 2017 19:44:09 +0800 Message-Id: <1513079049-8108-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [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: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Ye Ting Cc: Fu Siyuan Cc: Wang Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Fu Siyuan Reviewed-by: Ye Ting =20 --- .../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 /** --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel