From nobody Thu May 2 20:52:06 2024 Delivered-To: importer@patchew.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; Authentication-Results: mx.zoho.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 1489130198200608.2946645692045; Thu, 9 Mar 2017 23:16:38 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 371F0803AC; Thu, 9 Mar 2017 23:16:36 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 766B08038F for ; Thu, 9 Mar 2017 23:16:35 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 23:16:35 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by orsmga004.jf.intel.com with ESMTP; 09 Mar 2017 23:16:34 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,139,1486454400"; d="scan'208";a="66076663" From: Hao Wu To: edk2-devel@lists.01.org Date: Fri, 10 Mar 2017 15:16:27 +0800 Message-Id: <20170310071628.10044-2-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170310071628.10044-1-hao.a.wu@intel.com> References: <20170310071628.10044-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/CapsuleLib: Add lib destructors to handle unclosed events X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu 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" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Jiewen Yao --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 37 ++++++= +++++++++++--- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 3 +- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c | 33 ++++++= ++++++++--- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 4 ++- 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 7f500a96eb..a892892ccd 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -47,9 +47,11 @@ #include #include =20 -EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable =3D NULL; -BOOLEAN mIsVirtualAddrConverted =3D FALSE; -BOOLEAN mDxeCapsuleLibEndOfDxe =3D FALSE; +EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = =3D NULL; +BOOLEAN mIsVirtualAddrConverted = =3D FALSE; +BOOLEAN mDxeCapsuleLibEndOfDxe = =3D FALSE; +EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = =3D NULL; +EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = =3D NULL; =20 /** Initialize capsule related variables. @@ -1654,7 +1656,6 @@ DxeCapsuleLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_EVENT EndOfDxeEvent; EFI_STATUS Status; =20 Status =3D gBS->CreateEventEx ( @@ -1663,7 +1664,7 @@ DxeCapsuleLibConstructor ( DxeCapsuleLibEndOfDxe, NULL, &gEfiEndOfDxeEventGroupGuid, - &EndOfDxeEvent + &mDxeCapsuleLibEndOfDxeEvent ); ASSERT_EFI_ERROR (Status); =20 @@ -1671,3 +1672,29 @@ DxeCapsuleLibConstructor ( =20 return EFI_SUCCESS; } + +/** + The destructor function closes the End of DXE event. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor completed successfully. +**/ +EFI_STATUS +EFIAPI +DxeCapsuleLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Close the End of DXE event. + // + Status =3D gBS->CloseEvent (mDxeCapsuleLibEndOfDxeEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeM= odulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf index 5e437dc418..a6cf54cb6b 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf @@ -3,7 +3,7 @@ # # Capsule library instance for DXE_DRIVER module types. # -# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at @@ -23,6 +23,7 @@ VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D CapsuleLib|DXE_DRIVER UEFI_APPLICATION CONSTRUCTOR =3D DxeCapsuleLibConstructor + DESTRUCTOR =3D DxeCapsuleLibDestructor =20 # # The following information is for reference only and not required by the = build tools. diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/Md= eModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c index 880143905a..513aa533e1 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c @@ -1,7 +1,7 @@ /** @file Capsule library runtime support. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -28,6 +28,7 @@ =20 extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable; extern BOOLEAN mIsVirtualAddrConverted; +extern EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChange= Event; =20 /** Convert EsrtTable physical address to virtual address. @@ -92,21 +93,45 @@ DxeRuntimeCapsuleLibConstructor ( ) { EFI_STATUS Status; - EFI_EVENT Event; =20 // // Make sure we can handle virtual address changes. // - Event =3D NULL; Status =3D gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, DxeCapsuleLibVirtualAddressChangeEvent, NULL, &gEfiEventVirtualAddressChangeGuid, - &Event + &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent ); ASSERT_EFI_ERROR (Status); =20 return EFI_SUCCESS; } + +/** + The destructor function closes the VirtualAddressChange event. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor completed successfully. +**/ +EFI_STATUS +EFIAPI +DxeRuntimeCapsuleLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Close the VirtualAddressChange event. + // + Status =3D gBS->CloseEvent (mDxeRuntimeCapsuleLibVirtualAddressChangeEve= nt); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf= b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf index 47c67ccac5..25b7d51f57 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf @@ -3,7 +3,7 @@ # # Capsule library instance for DXE_RUNTIME_DRIVER module types. # -# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at @@ -24,6 +24,8 @@ LIBRARY_CLASS =3D CapsuleLib|DXE_RUNTIME_DRIVER CONSTRUCTOR =3D DxeCapsuleLibConstructor CONSTRUCTOR =3D DxeRuntimeCapsuleLibConstructor + DESTRUCTOR =3D DxeCapsuleLibDestructor + DESTRUCTOR =3D DxeRuntimeCapsuleLibDestructor =20 # # The following information is for reference only and not required by the = build tools. --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 20:52:06 2024 Delivered-To: importer@patchew.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; Authentication-Results: mx.zoho.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 1489130200259158.44937956731985; Thu, 9 Mar 2017 23:16:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 698A4803AB; Thu, 9 Mar 2017 23:16:38 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 31284803AF for ; Thu, 9 Mar 2017 23:16:37 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 23:16:36 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by orsmga004.jf.intel.com with ESMTP; 09 Mar 2017 23:16:36 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,139,1486454400"; d="scan'208";a="66076669" From: Hao Wu To: edk2-devel@lists.01.org Date: Fri, 10 Mar 2017 15:16:28 +0800 Message-Id: <20170310071628.10044-3-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170310071628.10044-1-hao.a.wu@intel.com> References: <20170310071628.10044-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH v2 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Jiewen Yao 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: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/= MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c index fc0f8698a9..3fed8e06e4 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c @@ -342,6 +342,10 @@ InitCapsuleLastVariable ( 0, NULL ); + } else { + if (CapsuleResult !=3D NULL) { + FreePool (CapsuleResult); + } } } =20 --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel