From f0dc9e15048818e01c0556e6c461271aa9000d05 Mon Sep 17 00:00:00 2001 From: Ken Lautner Date: Tue, 27 Aug 2024 13:21:47 -0700 Subject: [PATCH] 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 --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 6 ++++++ 1 file changed, 6 insertions(+) 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;