summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorKen Lautner <kenlautner3@gmail.com>2024-08-27 13:21:47 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-05 06:52:09 +0000
commitf0dc9e15048818e01c0556e6c461271aa9000d05 (patch)
tree26886c116fe8c309d31643569fbd61c7eba178d6 /MdeModulePkg
parent03bc4252fb68f0dcba72a19e1b2a861a5d6c927e (diff)
downloadedk2-f0dc9e15048818e01c0556e6c461271aa9000d05.tar.gz
edk2-f0dc9e15048818e01c0556e6c461271aa9000d05.tar.bz2
edk2-f0dc9e15048818e01c0556e6c461271aa9000d05.zip
MdeModulePkg: UefiBootManagerLib: Update assert condition
In BmFindBootOptionInVariable() we prevent passing a NULL pointer to EfiBootManagerFindLoadOption(). However, it can accept a NULL pointer as the second argument as long as count is zero. This change updates the assert condtion to only assert if the pointer is NULL and the count is non-zero. Signed-off-by: Kenneth Lautner <kenlautner3@gmail.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 7a97f7cdcc..8d62b0c558 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -147,6 +147,12 @@ BmFindBootOptionInVariable (
if (OptionNumber == LoadOptionNumberUnassigned) {
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
+ // Only assert if the BootOption is non-zero
+ if ((BootOptions == NULL) && (BootOptionCount > 0)) {
+ ASSERT (BootOptions != NULL);
+ return LoadOptionNumberUnassigned;
+ }
+
Index = EfiBootManagerFindLoadOption (OptionToFind, BootOptions, BootOptionCount);
if (Index != -1) {
OptionNumber = BootOptions[Index].OptionNumber;