From: "Ming Huang" <huangming@linux.alibaba.com>
To: devel@edk2.groups.io, sami.mujawar@arm.com,
ardb+tianocore@kernel.org, jiewen.yao@intel.com,
supreeth.venkatesh@arm.com
Cc: ming.huang-@outlook.com, Ming Huang <huangming@linux.alibaba.com>
Subject: [PATCH v1 1/2] StandaloneMmPkg/Hob: Assert or return NULL for create hob failed
Date: Wed, 9 Feb 2022 20:25:57 +0800 [thread overview]
Message-ID: <20220209122558.60329-2-huangming@linux.alibaba.com> (raw)
In-Reply-To: <20220209122558.60329-1-huangming@linux.alibaba.com>
The rare case (create hob failed) should be considered. Assert for
StandaloneMmCoreHobLib and return NULL for StandaloneMmobLib.
Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c | 6 ++++++
StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c | 3 +++
2 files changed, 9 insertions(+)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c
index 1550e1babc..d27e5ceaa4 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c
@@ -89,6 +89,7 @@ BuildModuleHob (
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
+ ASSERT (Hob != NULL);
CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);
Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
@@ -167,6 +168,7 @@ BuildGuidHob (
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+ ASSERT (Hob != NULL);
CopyGuid (&Hob->Name, Guid);
return Hob + 1;
}
@@ -226,6 +228,7 @@ BuildFvHob (
EFI_HOB_FIRMWARE_VOLUME *Hob;
Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
+ ASSERT (Hob != NULL);
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
@@ -255,6 +258,7 @@ BuildFv2Hob (
EFI_HOB_FIRMWARE_VOLUME2 *Hob;
Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));
+ ASSERT (Hob != NULL);
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
@@ -282,6 +286,7 @@ BuildCpuHob (
EFI_HOB_CPU *Hob;
Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));
+ ASSERT (Hob != NULL);
Hob->SizeOfMemorySpace = SizeOfMemorySpace;
Hob->SizeOfIoSpace = SizeOfIoSpace;
@@ -319,6 +324,7 @@ BuildMemoryAllocationHob (
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
+ ASSERT (Hob != NULL);
ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
diff --git a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
index ee61bdd227..4acd44ceb3 100644
--- a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
@@ -396,6 +396,9 @@ BuildGuidHob (
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+ if (Hob == NULL) {
+ return NULL;
+ }
CopyGuid (&Hob->Name, Guid);
return Hob + 1;
}
--
2.17.1
next prev parent reply other threads:[~2022-02-09 12:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 12:25 [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang
2022-02-09 12:25 ` Ming Huang [this message]
2022-02-09 12:25 ` [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue Ming Huang
2022-05-03 9:10 ` Ard Biesheuvel
2022-05-12 10:09 ` [edk2-devel] " Ming Huang
2023-08-16 8:55 ` Nhi Pham via groups.io
2023-08-30 13:10 ` Ard Biesheuvel
2023-08-31 8:20 ` Nhi Pham via groups.io
2023-09-01 20:43 ` Oliver Smith-Denny
2023-09-05 2:20 ` Nhi Pham via groups.io
2023-09-05 21:29 ` Oliver Smith-Denny
2023-09-06 6:33 ` Ni, Ray
2023-09-06 6:56 ` Ard Biesheuvel
2023-09-06 7:55 ` Nhi Pham via groups.io
2023-09-06 8:50 ` Ard Biesheuvel
2023-09-06 16:22 ` Oliver Smith-Denny
2023-09-07 15:38 ` Nhi Pham via groups.io
2023-11-30 13:59 ` Nhi Pham via groups.io
2023-12-01 5:29 ` Ni, Ray
2023-09-06 7:35 ` Nhi Pham via groups.io
[not found] ` <177BD141FD103BE4.8497@groups.io>
2023-08-29 2:48 ` Nhi Pham via groups.io
2022-03-30 9:35 ` [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang
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=20220209122558.60329-2-huangming@linux.alibaba.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