From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 BEF3A81CE2 for ; Sun, 20 Nov 2016 17:29:25 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 20 Nov 2016 17:29:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,524,1473145200"; d="scan'208";a="903776452" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 20 Nov 2016 17:29:25 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 20 Nov 2016 17:29:24 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 20 Nov 2016 17:29:24 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.239]) with mapi id 14.03.0248.002; Mon, 21 Nov 2016 09:29:22 +0800 From: "Yao, Jiewen" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [edk2] [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable Thread-Index: AQHSQ5VXn7y5phUpsEOH0SIZISNdbKDiphEQ Date: Mon, 21 Nov 2016 01:29:22 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C50386D7EC4@shsmsx102.ccr.corp.intel.com> References: <1479691117-69060-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1479691117-69060-1-git-send-email-dandan.bi@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] 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:29:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks. I think we should check allocation result to see if it is NULL. + CapsuleResultVariable =3D AllocatePool (CapsuleResultVariableSize); + CapsuleResultVariableHeader =3D (VOID *)CapsuleResultVariable; Thank you Yao Jiewen > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > 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 > 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) + > 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 > sizeof(CapsuleResultVariable); > + CapsuleResultVariableSize =3D > sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + > sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP); > + CapsuleResultVariable =3D AllocatePool (CapsuleResultVariableSize); > + CapsuleResultVariableHeader =3D (VOID *)CapsuleResultVariable; > + 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