public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Bi, Dandan" <dandan.bi@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable
Date: Mon, 21 Nov 2016 02:48:15 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C50386D7F7F@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1479692941-68464-1-git-send-email-dandan.bi@intel.com>

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 <jiewen.yao@intel.com>
> Subject: [edk2] [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Use
> AllocatePool for CapsuleResultVariable
> 
> V2: Add check for the result of AllocatePool function.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c   | 20
> ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> 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;
> 
> -  CapsuleResultVariableHeader = (VOID *)&CapsuleResultVariable[0];
> -  CapsuleResultVariableHeader->VariableTotalSize =
> sizeof(CapsuleResultVariable);
> +  CapsuleResultVariable     = NULL;
> +  CapsuleResultVariableSize =
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) +
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP);
> +  CapsuleResultVariable     = AllocatePool (CapsuleResultVariableSize);
> +  if (CapsuleResultVariable == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +  CapsuleResultVariableHeader = (VOID *)CapsuleResultVariable;
> +  CapsuleResultVariableHeader->VariableTotalSize =
> CapsuleResultVariableSize;
>    CopyGuid(&CapsuleResultVariableHeader->CapsuleGuid,
> &CapsuleHeader->CapsuleGuid);
>    ZeroMem(&CapsuleResultVariableHeader->CapsuleProcessed,
> sizeof(CapsuleResultVariableHeader->CapsuleProcessed));
>    gRT->GetTime(&CapsuleResultVariableHeader->CapsuleProcessed,
> NULL);
>    CapsuleResultVariableHeader->CapsuleStatus = CapsuleStatus;
> 
> -  CapsuleResultVariableFmp = (VOID
> *)&CapsuleResultVariable[sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)
> ];
> +  CapsuleResultVariableFmp = (VOID *)(CapsuleResultVariable +
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER));
>    CapsuleResultVariableFmp->Version = 0x1;
>    CapsuleResultVariableFmp->PayloadIndex = (UINT8)PayloadIndex;
>    CapsuleResultVariableFmp->UpdateImageIndex =
> ImageHeader->UpdateImageIndex;
>    CopyGuid (&CapsuleResultVariableFmp->UpdateImageTypeId,
> &ImageHeader->UpdateImageTypeId);
> 
>    //
>    // Save Local Cache
>    //
> -  Status = WriteNewCapsuleResultVariableCache(&CapsuleResultVariable,
> sizeof(CapsuleResultVariable));
> +  Status = WriteNewCapsuleResultVariableCache(CapsuleResultVariable,
> CapsuleResultVariableSize);
> 
>    if ((CapsuleHeader->Flags &
> CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
> -    Status = WriteNewCapsuleResultVariable(&CapsuleResultVariable,
> sizeof(CapsuleResultVariable));
> +    Status = WriteNewCapsuleResultVariable(CapsuleResultVariable,
> CapsuleResultVariableSize);
>    }
> +  FreePool (CapsuleResultVariable);
>    return Status;
>  }
> 
>  /**
>    Initialize CapsuleMax variables.
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2016-11-21  2:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21  1:49 [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable Dandan Bi
2016-11-21  2:48 ` Yao, Jiewen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74D8A39837DF1E4DA445A8C0B3885C50386D7F7F@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox