From ce5fad41516804f34d52ebb27808255e1263fd0e Mon Sep 17 00:00:00 2001 From: xli24 Date: Fri, 21 May 2010 07:40:24 +0000 Subject: For BdsDxe module, 1. Fix the risk that local variable is pointed by global pointer, which may be used outside the variable scope. 2. Add more checking for pointers. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10536 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/BdsDxe/BootMngr/BootManager.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr') diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c index 01ff5f88ad..da291000bc 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c @@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UINT16 mKeyInput; EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID; -LIST_ENTRY *mBootOptionsList; +LIST_ENTRY mBootOptionsList; BDS_COMMON_OPTION *gOption; HII_VENDOR_DEVICE_PATH mBootManagerHiiVendorDevicePath = { @@ -97,7 +97,7 @@ BootManagerCallback ( // KeyCount = 0; - for (Link = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) { + for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); KeyCount++; @@ -190,7 +190,6 @@ CallBootManager ( UINTN ExitDataSize; EFI_STRING_ID Token; EFI_INPUT_KEY Key; - LIST_ENTRY BdsBootOptionList; CHAR16 *HelpString; EFI_STRING_ID HelpToken; UINT16 *TempStr; @@ -203,7 +202,7 @@ CallBootManager ( EFI_IFR_GUID_LABEL *EndLabel; gOption = NULL; - InitializeListHead (&BdsBootOptionList); + InitializeListHead (&mBootOptionsList); // // Connect all prior to entering the platform setup menu. @@ -212,14 +211,8 @@ CallBootManager ( BdsLibConnectAllDriversToAllControllers (); gConnectAllHappened = TRUE; } - // - // BugBug: Here we can not remove the legacy refresh macro, so we need - // get the boot order every time from "BootOrder" variable. - // Recreate the boot option list base on the BootOrder variable - // - BdsLibEnumerateAllBootOption (&BdsBootOptionList); - mBootOptionsList = &BdsBootOptionList; + BdsLibEnumerateAllBootOption (&mBootOptionsList); HiiHandle = gBootManagerPrivate.HiiHandle; @@ -248,7 +241,7 @@ CallBootManager ( mKeyInput = 0; - for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) { + for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); // -- cgit v1.2.3