From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 700A5803A7 for ; Thu, 9 Mar 2017 23:02:21 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 23:02:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,139,1486454400"; d="scan'208";a="833048506" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 09 Mar 2017 23:02:20 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Mar 2017 23:02:20 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.59]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.177]) with mapi id 14.03.0248.002; Fri, 10 Mar 2017 15:02:18 +0800 From: "Wu, Hao A" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH 2/2] MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API Thread-Index: AQHSmWSLAXF50oAvoUS/YCAK1OkGlqGNEuGAgACSkpA= Date: Fri, 10 Mar 2017 07:02:18 +0000 Message-ID: References: <20170310060700.10076-1-hao.a.wu@intel.com> <20170310060700.10076-3-hao.a.wu@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503A901B2E@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A901B2E@shsmsx102.ccr.corp.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 07:02:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Yao, Jiewen > Sent: Friday, March 10, 2017 2:17 PM > To: Wu, Hao A; edk2-devel@lists.01.org > Subject: RE: [PATCH 2/2] MdeModulePkg/CapsuleLib: Free the buffer returne= d > by GetVariable2 API >=20 > According to GetVariable2() API, there is no guarantee that Data will be = NULL, > if error is returned. >=20 > I suggest we use status check instead of data pointer check. >=20 Yes, you are right. I will send out a V2 version of the series. Best Regards, Hao Wu >=20 > /** > Returns the status whether get the variable success. The function retri= eves > variable through the UEFI Runtime Service GetVariable(). The > returned buffer is allocated using AllocatePool(). The caller is respo= nsible > for freeing this buffer with FreePool(). >=20 > If Name is NULL, then ASSERT(). > If Guid is NULL, then ASSERT(). > If Value is NULL, then ASSERT(). >=20 > @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. >=20 > @return EFI_OUT_OF_RESOURCES Allocate buffer failed. > @return EFI_SUCCESS Find the specified variable. > @return Others Errors Return errors from call to gRT->GetVa= riable. >=20 > **/ >=20 >=20 >=20 > > -----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 > > > > 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(+) > > > > 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); > > + } > > } > > > > // Lock it in normal boot path per UEFI spec. > > -- > > 2.12.0.windows.1