From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 5972481D3E for ; Sun, 20 Nov 2016 17:32:32 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 20 Nov 2016 17:32:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,524,1473145200"; d="scan'208";a="1071342362" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 20 Nov 2016 17:32:31 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 20 Nov 2016 17:32:31 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 20 Nov 2016 17:32:30 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Mon, 21 Nov 2016 09:32:27 +0800 From: "Bi, Dandan" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Bi, Dandan" Thread-Topic: [edk2] [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable Thread-Index: AQHSQ5VXx3Ev63+mOEm/Q7dgk2a+c6DiIBgAgACGcrA= Date: Mon, 21 Nov 2016 01:32:27 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB39661544@shsmsx102.ccr.corp.intel.com> References: <1479691117-69060-1-git-send-email-dandan.bi@intel.com> <74D8A39837DF1E4DA445A8C0B3885C50386D7EC4@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C50386D7EC4@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable 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: Mon, 21 Nov 2016 01:32:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes, that's right! I will update it. Thanks! Thanks, Dandan -----Original Message----- From: Yao, Jiewen=20 Sent: Monday, November 21, 2016 9:29 AM To: Bi, Dandan ; edk2-devel@lists.01.org Cc: Yao, Jiewen Subject: RE: [edk2] [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool= for CapsuleResultVariable Thanks. I think we should check allocation result to see if it is NULL. + CapsuleResultVariable =3D AllocatePool (CapsuleResultVariableSize); =20 + CapsuleResultVariableHeader =3D (VOID *)CapsuleResultVariable; Thank you Yao Jiewen > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Dandan Bi > Sent: Monday, November 21, 2016 9:19 AM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen > Subject: [edk2] [patch] MdeModulePkg/DxeCapsuleLibFmp: Use=20 > AllocatePool for CapsuleResultVariable >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > .../Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 16 > ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) >=20 > diff --git > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > index a0ed2d0..237c552 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > @@ -289,36 +289,40 @@ RecordFmpCapsuleStatusVariable ( > IN EFI_STATUS > CapsuleStatus, > IN UINTN > PayloadIndex, > IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER > *ImageHeader > ) > { > - UINT8 > CapsuleResultVariable[sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) +=20 > sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP)]; > EFI_CAPSULE_RESULT_VARIABLE_HEADER > *CapsuleResultVariableHeader; > EFI_CAPSULE_RESULT_VARIABLE_FMP *CapsuleResultVariableFmp; > EFI_STATUS Status; > + UINT8 *CapsuleResultVariable; > + UINT32 CapsuleResultVariableSize; >=20 > - CapsuleResultVariableHeader =3D (VOID *)&CapsuleResultVariable[0]; > - CapsuleResultVariableHeader->VariableTotalSize =3D=20 > sizeof(CapsuleResultVariable); > + CapsuleResultVariableSize =3D > sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) +=20 > sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP); > + CapsuleResultVariable =3D AllocatePool (CapsuleResultVariableSize); =20 > + CapsuleResultVariableHeader =3D (VOID *)CapsuleResultVariable; =20 > + CapsuleResultVariableHeader->VariableTotalSize =3D > CapsuleResultVariableSize; > CopyGuid(&CapsuleResultVariableHeader->CapsuleGuid, > &CapsuleHeader->CapsuleGuid); > ZeroMem(&CapsuleResultVariableHeader->CapsuleProcessed, > sizeof(CapsuleResultVariableHeader->CapsuleProcessed)); > gRT->GetTime(&CapsuleResultVariableHeader->CapsuleProcessed, > NULL); > CapsuleResultVariableHeader->CapsuleStatus =3D CapsuleStatus; >=20 > - CapsuleResultVariableFmp =3D (VOID > *)&CapsuleResultVariable[sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) > ]; > + CapsuleResultVariableFmp =3D (VOID *)(CapsuleResultVariable + > sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)); > CapsuleResultVariableFmp->Version =3D 0x1; > CapsuleResultVariableFmp->PayloadIndex =3D (UINT8)PayloadIndex; > CapsuleResultVariableFmp->UpdateImageIndex =3D > ImageHeader->UpdateImageIndex; > CopyGuid (&CapsuleResultVariableFmp->UpdateImageTypeId, > &ImageHeader->UpdateImageTypeId); >=20 > // > // Save Local Cache > // > - Status =3D WriteNewCapsuleResultVariableCache(&CapsuleResultVariable, > sizeof(CapsuleResultVariable)); > + Status =3D WriteNewCapsuleResultVariableCache(CapsuleResultVariable, > CapsuleResultVariableSize); >=20 > if ((CapsuleHeader->Flags & > CAPSULE_FLAGS_PERSIST_ACROSS_RESET) !=3D 0) { > - Status =3D WriteNewCapsuleResultVariable(&CapsuleResultVariable, > sizeof(CapsuleResultVariable)); > + Status =3D WriteNewCapsuleResultVariable(CapsuleResultVariable, > CapsuleResultVariableSize); > } > + FreePool (CapsuleResultVariable); > return Status; > } >=20 > /** > Initialize CapsuleMax variables. > -- > 1.9.5.msysgit.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel