* [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable
@ 2016-11-21 1:18 Dandan Bi
2016-11-21 1:29 ` Yao, Jiewen
0 siblings, 1 reply; 3+ messages in thread
From: Dandan Bi @ 2016-11-21 1:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Jiewen Yao
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 | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
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;
- CapsuleResultVariableHeader = (VOID *)&CapsuleResultVariable[0];
- CapsuleResultVariableHeader->VariableTotalSize = sizeof(CapsuleResultVariable);
+ CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP);
+ CapsuleResultVariable = AllocatePool (CapsuleResultVariableSize);
+ 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable
2016-11-21 1:18 [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable Dandan Bi
@ 2016-11-21 1:29 ` Yao, Jiewen
2016-11-21 1:32 ` Bi, Dandan
0 siblings, 1 reply; 3+ messages in thread
From: Yao, Jiewen @ 2016-11-21 1:29 UTC (permalink / raw)
To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Yao, Jiewen
Thanks.
I think we should check allocation result to see if it is NULL.
+ CapsuleResultVariable = AllocatePool (CapsuleResultVariableSize);
+ CapsuleResultVariableHeader = (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 <jiewen.yao@intel.com>
> Subject: [edk2] [patch] MdeModulePkg/DxeCapsuleLibFmp: Use
> AllocatePool for CapsuleResultVariable
>
> 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 | 16
> ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> 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;
>
> - CapsuleResultVariableHeader = (VOID *)&CapsuleResultVariable[0];
> - CapsuleResultVariableHeader->VariableTotalSize =
> sizeof(CapsuleResultVariable);
> + CapsuleResultVariableSize =
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) +
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP);
> + CapsuleResultVariable = AllocatePool (CapsuleResultVariableSize);
> + 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable
2016-11-21 1:29 ` Yao, Jiewen
@ 2016-11-21 1:32 ` Bi, Dandan
0 siblings, 0 replies; 3+ messages in thread
From: Bi, Dandan @ 2016-11-21 1:32 UTC (permalink / raw)
To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Bi, Dandan
Yes, that's right! I will update it. Thanks!
Thanks,
Dandan
-----Original Message-----
From: Yao, Jiewen
Sent: Monday, November 21, 2016 9:29 AM
To: Bi, Dandan <dandan.bi@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>
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 = AllocatePool (CapsuleResultVariableSize);
+ CapsuleResultVariableHeader = (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 <jiewen.yao@intel.com>
> Subject: [edk2] [patch] MdeModulePkg/DxeCapsuleLibFmp: Use
> AllocatePool for CapsuleResultVariable
>
> 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 | 16
> ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> 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;
>
> - CapsuleResultVariableHeader = (VOID *)&CapsuleResultVariable[0];
> - CapsuleResultVariableHeader->VariableTotalSize =
> sizeof(CapsuleResultVariable);
> + CapsuleResultVariableSize =
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) +
> sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP);
> + CapsuleResultVariable = AllocatePool (CapsuleResultVariableSize);
> + 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-21 1:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-21 1:18 [patch] MdeModulePkg/DxeCapsuleLibFmp: Use AllocatePool for CapsuleResultVariable Dandan Bi
2016-11-21 1:29 ` Yao, Jiewen
2016-11-21 1:32 ` Bi, Dandan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox