]> xenbits.xensource.com Git - people/aperard/ovmf.git/commitdiff
MdeModulePkg: UefiBootManagerLib: Update assert condition
authorKen Lautner <kenlautner3@gmail.com>
Tue, 27 Aug 2024 20:21:47 +0000 (13:21 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 5 Sep 2024 06:52:09 +0000 (06:52 +0000)
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>
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c

index 7a97f7cdcc6b32106348e9e73889a82f9dca1c4a..8d62b0c55835e9449b8214a5b9a42feb458f7191 100644 (file)
@@ -147,6 +147,12 @@ BmFindBootOptionInVariable (
   if (OptionNumber == LoadOptionNumberUnassigned) {\r
     BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
 \r
+    // Only assert if the BootOption is non-zero\r
+    if ((BootOptions == NULL) && (BootOptionCount > 0)) {\r
+      ASSERT (BootOptions != NULL);\r
+      return LoadOptionNumberUnassigned;\r
+    }\r
+\r
     Index = EfiBootManagerFindLoadOption (OptionToFind, BootOptions, BootOptionCount);\r
     if (Index != -1) {\r
       OptionNumber = BootOptions[Index].OptionNumber;\r