public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()
@ 2024-03-12  9:27 Du Lin
  2024-03-13  1:46 ` Chen, Gang C
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Du Lin @ 2024-03-12  9:27 UTC (permalink / raw)
  To: devel
  Cc: Du Lin, Ashraf Ali S, Chasel Chiu, Chen Gang C, Duggapu Chinni B,
	Nate DeSimone, Star Zeng, Susovan Mohapatra, Ted Kuo

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4701

The error handling of FspmWrapperInit() is limited to ASSERT
statements only, which only works in debug builds, but not in
release builds.
Fix the issue by enhancing the error handling of FspmWrapperInit()
to cover both debug builds and release builds.

Signed-off-by: Du Lin <du.lin@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Chen Gang C <gang.c.chen@intel.com>
Cc: Duggapu Chinni B <chinni.b.duggapu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Susovan Mohapatra <susovan.mohapatra@intel.com>
Cc: Ted Kuo <ted.kuo@intel.com>
---
 .../FspmWrapperPeim/FspmWrapperPeim.c                | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
index ba0c742fea..356baeeccf 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
@@ -196,13 +196,21 @@ FspmWrapperInit (
   EFI_PEI_PPI_DESCRIPTOR                                 *MeasurementExcludedPpiList;
 
   MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));
-  ASSERT (MeasurementExcludedFvPpi != NULL);
+  if (MeasurementExcludedFvPpi == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   MeasurementExcludedFvPpi->Count          = 1;
   MeasurementExcludedFvPpi->Fv[0].FvBase   = PcdGet32 (PcdFspmBaseAddress);
   MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspmBaseAddress))->FvLength;
 
   MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));
-  ASSERT (MeasurementExcludedPpiList != NULL);
+  if (MeasurementExcludedPpiList == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
   MeasurementExcludedPpiList->Guid  = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
   MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
-- 
2.44.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116686): https://edk2.groups.io/g/devel/message/116686
Mute This Topic: https://groups.io/mt/104886876/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()
  2024-03-12  9:27 [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit() Du Lin
@ 2024-03-13  1:46 ` Chen, Gang C
  2024-03-13  6:55 ` Ashraf Ali S
  2024-03-13  9:57 ` Ni, Ray
  2 siblings, 0 replies; 5+ messages in thread
From: Chen, Gang C @ 2024-03-13  1:46 UTC (permalink / raw)
  To: Lin, Du, devel@edk2.groups.io
  Cc: S, Ashraf Ali, Chiu, Chasel, Duggapu, Chinni B,
	Desimone, Nathaniel L, Zeng, Star, Mohapatra, Susovan, Kuo, Ted

Reviewed-by: Chen Gang C <gang.c.chen@intel.com>

BR
Gang

-----Original Message-----
From: Lin, Du <du.lin@intel.com> 
Sent: Tuesday, March 12, 2024 5:28 PM
To: devel@edk2.groups.io
Cc: Lin, Du <du.lin@intel.com>; S, Ashraf Ali <ashraf.ali.s@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Chen, Gang C <gang.c.chen@intel.com>; Duggapu, Chinni B <chinni.b.duggapu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Mohapatra, Susovan <susovan.mohapatra@intel.com>; Kuo, Ted <ted.kuo@intel.com>
Subject: [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4701

The error handling of FspmWrapperInit() is limited to ASSERT statements only, which only works in debug builds, but not in release builds.
Fix the issue by enhancing the error handling of FspmWrapperInit() to cover both debug builds and release builds.

Signed-off-by: Du Lin <du.lin@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Chen Gang C <gang.c.chen@intel.com>
Cc: Duggapu Chinni B <chinni.b.duggapu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Susovan Mohapatra <susovan.mohapatra@intel.com>
Cc: Ted Kuo <ted.kuo@intel.com>
---
 .../FspmWrapperPeim/FspmWrapperPeim.c                | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
index ba0c742fea..356baeeccf 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
@@ -196,13 +196,21 @@ FspmWrapperInit (
   EFI_PEI_PPI_DESCRIPTOR                                 *MeasurementExcludedPpiList;
 
   MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));
-  ASSERT (MeasurementExcludedFvPpi != NULL);
+  if (MeasurementExcludedFvPpi == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   MeasurementExcludedFvPpi->Count          = 1;
   MeasurementExcludedFvPpi->Fv[0].FvBase   = PcdGet32 (PcdFspmBaseAddress);
   MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspmBaseAddress))->FvLength;
 
   MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));
-  ASSERT (MeasurementExcludedPpiList != NULL);
+  if (MeasurementExcludedPpiList == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
   MeasurementExcludedPpiList->Guid  = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
   MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
--
2.44.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116699): https://edk2.groups.io/g/devel/message/116699
Mute This Topic: https://groups.io/mt/104886876/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()
  2024-03-12  9:27 [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit() Du Lin
  2024-03-13  1:46 ` Chen, Gang C
@ 2024-03-13  6:55 ` Ashraf Ali S
  2024-03-13  9:57 ` Ni, Ray
  2 siblings, 0 replies; 5+ messages in thread
From: Ashraf Ali S @ 2024-03-13  6:55 UTC (permalink / raw)
  To: Lin, Du, devel@edk2.groups.io
  Cc: Chiu, Chasel, Chen, Gang C, Duggapu, Chinni B,
	Desimone, Nathaniel L, Zeng, Star, Mohapatra, Susovan, Kuo, Ted

Reviewed-by: S, Ashraf Ali <ashraf.ali.s@intel.com>

Thanks.,
S, Ashraf Ali

-----Original Message-----
From: Lin, Du <du.lin@intel.com> 
Sent: Tuesday, March 12, 2024 2:58 PM
To: devel@edk2.groups.io
Cc: Lin, Du <du.lin@intel.com>; S, Ashraf Ali <ashraf.ali.s@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Chen, Gang C <gang.c.chen@intel.com>; Duggapu, Chinni B <chinni.b.duggapu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; Mohapatra, Susovan <susovan.mohapatra@intel.com>; Kuo, Ted <ted.kuo@intel.com>
Subject: [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4701

The error handling of FspmWrapperInit() is limited to ASSERT statements only, which only works in debug builds, but not in release builds.
Fix the issue by enhancing the error handling of FspmWrapperInit() to cover both debug builds and release builds.

Signed-off-by: Du Lin <du.lin@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Chen Gang C <gang.c.chen@intel.com>
Cc: Duggapu Chinni B <chinni.b.duggapu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Susovan Mohapatra <susovan.mohapatra@intel.com>
Cc: Ted Kuo <ted.kuo@intel.com>
---
 .../FspmWrapperPeim/FspmWrapperPeim.c                | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
index ba0c742fea..356baeeccf 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
@@ -196,13 +196,21 @@ FspmWrapperInit (
   EFI_PEI_PPI_DESCRIPTOR                                 *MeasurementExcludedPpiList;
 
   MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));
-  ASSERT (MeasurementExcludedFvPpi != NULL);
+  if (MeasurementExcludedFvPpi == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   MeasurementExcludedFvPpi->Count          = 1;
   MeasurementExcludedFvPpi->Fv[0].FvBase   = PcdGet32 (PcdFspmBaseAddress);
   MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspmBaseAddress))->FvLength;
 
   MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));
-  ASSERT (MeasurementExcludedPpiList != NULL);
+  if (MeasurementExcludedPpiList == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
   MeasurementExcludedPpiList->Guid  = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
   MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
--
2.44.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116707): https://edk2.groups.io/g/devel/message/116707
Mute This Topic: https://groups.io/mt/104886876/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()
  2024-03-12  9:27 [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit() Du Lin
  2024-03-13  1:46 ` Chen, Gang C
  2024-03-13  6:55 ` Ashraf Ali S
@ 2024-03-13  9:57 ` Ni, Ray
  2024-03-14  2:32   ` Du Lin
  2 siblings, 1 reply; 5+ messages in thread
From: Ni, Ray @ 2024-03-13  9:57 UTC (permalink / raw)
  To: devel@edk2.groups.io, Lin, Du
  Cc: S, Ashraf Ali, Chiu, Chasel, Chen, Gang C, Duggapu, Chinni B,
	Desimone, Nathaniel L, Zeng, Star, Mohapatra, Susovan, Kuo, Ted

> -  ASSERT (MeasurementExcludedFvPpi != NULL);
> +  if (MeasurementExcludedFvPpi == NULL) {
> +    ASSERT (FALSE);

I prefer the original meaningful assertion instead of ASSERT (FALSE).
Adding if-check is a good change to me.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116713): https://edk2.groups.io/g/devel/message/116713
Mute This Topic: https://groups.io/mt/104886876/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit()
  2024-03-13  9:57 ` Ni, Ray
@ 2024-03-14  2:32   ` Du Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Du Lin @ 2024-03-14  2:32 UTC (permalink / raw)
  To: Ni, Ray, devel

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

This patch has been updated to address Ray's comment. For more details, please check [PATCH v2] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit() (groups.io) ( https://edk2.groups.io/g/devel/message/116723 ). Thanks Ray for the comment.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116725): https://edk2.groups.io/g/devel/message/116725
Mute This Topic: https://groups.io/mt/104886876/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 1038 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-14  2:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12  9:27 [edk2-devel] [PATCH] IntelFsp2WrapperPkg: Error handling of FspmWrapperInit() Du Lin
2024-03-13  1:46 ` Chen, Gang C
2024-03-13  6:55 ` Ashraf Ali S
2024-03-13  9:57 ` Ni, Ray
2024-03-14  2:32   ` Du Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox