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 2190C81DC7 for ; Sun, 20 Nov 2016 18:48:21 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 20 Nov 2016 18:48:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,524,1473145200"; d="scan'208";a="33729063" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 20 Nov 2016 18:48:20 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 20 Nov 2016 18:48:20 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 20 Nov 2016 18:48:20 -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 10:48:16 +0800 From: "Yao, Jiewen" To: "Bi, Dandan" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable Thread-Index: AQHSQ5mMTdgYmyvTGk+xxu8ybtT4NaDivCxw Date: Mon, 21 Nov 2016 02:48:15 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C50386D7F7F@shsmsx102.ccr.corp.intel.com> References: <1479692941-68464-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1479692941-68464-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 v2] 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 02:48:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: jiewen.yao@intel.com > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Dandan Bi > Sent: Monday, November 21, 2016 9:49 AM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen > Subject: [edk2] [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Use > AllocatePool for CapsuleResultVariable >=20 > V2: Add check for the result of AllocatePool function. >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > .../Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 20 > ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) >=20 > diff --git > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > index a0ed2d0..2546871 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c > @@ -289,36 +289,44 @@ 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); > + CapsuleResultVariable =3D NULL; > + CapsuleResultVariableSize =3D > sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + > sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP); > + CapsuleResultVariable =3D AllocatePool (CapsuleResultVariableSize)= ; > + if (CapsuleResultVariable =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + 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