From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4FFC3803A7 for ; Thu, 9 Mar 2017 22:16:47 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 22:16:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,139,1486454400"; d="scan'208";a="75000327" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 09 Mar 2017 22:16:46 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Mar 2017 22:16:46 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Mar 2017 22:16:46 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Fri, 10 Mar 2017 14:16:43 +0800 From: "Yao, Jiewen" To: "Wu, Hao A" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API Thread-Index: AQHSmWSLzAop5TPYPU6VA+R3U3lzYKGNmJKg Date: Fri, 10 Mar 2017 06:16:43 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A901B2E@shsmsx102.ccr.corp.intel.com> References: <20170310060700.10076-1-hao.a.wu@intel.com> <20170310060700.10076-3-hao.a.wu@intel.com> In-Reply-To: <20170310060700.10076-3-hao.a.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 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: , X-List-Received-Date: Fri, 10 Mar 2017 06:16:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable According to GetVariable2() API, there is no guarantee that Data will be NU= LL, if error is returned. I suggest we use status check instead of data pointer check. /** Returns the status whether get the variable success. The function retriev= es=20 variable through the UEFI Runtime Service GetVariable(). The=20 returned buffer is allocated using AllocatePool(). The caller is respons= ible for freeing this buffer with FreePool(). If Name is NULL, then ASSERT(). If Guid is NULL, then ASSERT(). If Value is NULL, then ASSERT(). @param[in] Name The pointer to a Null-terminated Unicode string. @param[in] Guid The pointer to an EFI_GUID structure @param[out] Value The buffer point saved the variable info. @param[out] Size The buffer size of the variable. @return EFI_OUT_OF_RESOURCES Allocate buffer failed. @return EFI_SUCCESS Find the specified variable. @return Others Errors Return errors from call to gRT->GetVari= able. **/ > -----Original Message----- > From: Wu, Hao A > Sent: Friday, March 10, 2017 2:07 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Yao, Jiewen > Subject: [PATCH 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by > GetVariable2 API >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > index fc0f8698a9..191a432369 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > @@ -343,6 +343,9 @@ InitCapsuleLastVariable ( > NULL > ); > } > + if (CapsuleResult !=3D NULL) { > + FreePool (CapsuleResult); > + } > } >=20 > // Lock it in normal boot path per UEFI spec. > -- > 2.12.0.windows.1