From 6e74560f20c54a4ec3577fdfe2e9e7fa3e8b2f21 Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Tue, 24 Sep 2013 10:08:04 +0000 Subject: Fix deadloop issue in BrowserCallback function. Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14711 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 10 ---- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 63 ++++++++++++++++------- MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 1 - 3 files changed, 43 insertions(+), 31 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index ac7dce694b..4006fcd6fc 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -510,10 +510,6 @@ CreateStorage ( InitializeConfigHdr (FormSet, BrowserStorage); } - // - // Add count because one formset storage use this global storage. - // - BrowserStorage->ReferenceCount++; Storage->BrowserStorage = BrowserStorage; Storage->ConfigRequest = AllocateCopyPool (StrSize (BrowserStorage->ConfigHdr), BrowserStorage->ConfigHdr); @@ -742,12 +738,6 @@ DestroyStorage ( FreePool (Storage->ConfigRequest); } - // - // Minus the reference to the global storage. - // - ASSERT (Storage->BrowserStorage->ReferenceCount > 0); - Storage->BrowserStorage->ReferenceCount--; - FreePool (Storage); } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 63f86809fa..7cba785a88 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -53,6 +53,7 @@ BOOLEAN gExitRequired; BROWSER_SETTING_SCOPE gBrowserSettingScope = FormSetLevel; BOOLEAN mBrowserScopeFirstSet = TRUE; EXIT_HANDLER ExitHandlerFunction = NULL; +FORM_BROWSER_FORMSET *mSystemLevelFormSet; // // Browser Global Strings @@ -255,6 +256,9 @@ LoadAllHiiFormset ( UINTN Index; EFI_GUID ZeroGuid; EFI_STATUS Status; + FORM_BROWSER_FORMSET *OldFormset; + + OldFormset = mSystemLevelFormSet; // // Get all the Hii handles @@ -278,6 +282,8 @@ LoadAllHiiFormset ( // LocalFormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET)); ASSERT (LocalFormSet != NULL); + mSystemLevelFormSet = LocalFormSet; + ZeroMem (&ZeroGuid, sizeof (ZeroGuid)); Status = InitializeFormSet (HiiHandles[Index], &ZeroGuid, LocalFormSet); if (EFI_ERROR (Status) || IsListEmpty (&LocalFormSet->FormListHead)) { @@ -300,6 +306,8 @@ LoadAllHiiFormset ( // Free resources, and restore gOldFormSet and gClassOfVfr // FreePool (HiiHandles); + + mSystemLevelFormSet = OldFormset; } /** @@ -388,6 +396,7 @@ SendForm ( break; } Selection->FormSet = FormSet; + mSystemLevelFormSet = FormSet; // // Display this formset @@ -397,6 +406,7 @@ SendForm ( Status = SetupBrowser (Selection); gCurrentSelection = NULL; + mSystemLevelFormSet = NULL; // // If no data is changed, don't need to save current FormSet into the maintain list. @@ -580,7 +590,6 @@ BrowserCallback ( LIST_ENTRY *Link; BROWSER_STORAGE *Storage; FORMSET_STORAGE *FormsetStorage; - FORM_BROWSER_FORMSET *FormSet; UINTN TotalSize; BOOLEAN Found; @@ -650,16 +659,15 @@ BrowserCallback ( // // GUID/Name is not specified, take the first storage in FormSet // - if (gCurrentSelection == NULL) { + if (mSystemLevelFormSet == NULL) { return EFI_NOT_READY; } // // Generate // - FormSet = gCurrentSelection->FormSet; - Link = GetFirstNode (&FormSet->StorageListHead); - if (IsNull (&FormSet->StorageListHead, Link)) { + Link = GetFirstNode (&mSystemLevelFormSet->StorageListHead); + if (IsNull (&mSystemLevelFormSet->StorageListHead, Link)) { return EFI_UNSUPPORTED; } @@ -2361,7 +2369,8 @@ DiscardForm ( LIST_ENTRY *Link; FORMSET_STORAGE *Storage; FORM_BROWSER_CONFIG_REQUEST *ConfigInfo; - FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *OldFormSet; // // Check the supported setting level. @@ -2440,7 +2449,8 @@ DiscardForm ( // // System Level Discard. // - + OldFormSet = mSystemLevelFormSet; + // // Discard changed value for each FormSet in the maintain list. // @@ -2451,6 +2461,9 @@ DiscardForm ( if (!ValidateFormSet(LocalFormSet)) { continue; } + + mSystemLevelFormSet = LocalFormSet; + DiscardForm (LocalFormSet, NULL, FormSetLevel); if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) { // @@ -2461,6 +2474,8 @@ DiscardForm ( DestroyFormSet (LocalFormSet); } } + + mSystemLevelFormSet = OldFormSet; } return EFI_SUCCESS; @@ -3402,6 +3417,7 @@ ExtractDefault ( LIST_ENTRY *Link; FORM_BROWSER_STATEMENT *Question; FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *OldFormSet; Status = EFI_SUCCESS; @@ -3485,7 +3501,9 @@ ExtractDefault ( // Preload all Hii formset. // LoadAllHiiFormset(); - + + OldFormSet = mSystemLevelFormSet; + // // Set Default Value for each FormSet in the maintain list. // @@ -3496,8 +3514,13 @@ ExtractDefault ( if (!ValidateFormSet(LocalFormSet)) { continue; } + + mSystemLevelFormSet = LocalFormSet; + ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst); } + + mSystemLevelFormSet = OldFormSet; } return EFI_SUCCESS; @@ -4210,7 +4233,7 @@ LoadStorage ( return; case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER: - if (Storage->BrowserStorage->ReferenceCount > 1) { + if (Storage->BrowserStorage->ConfigRequest != NULL) { ConfigRequestAdjust(Storage); return; } @@ -4311,6 +4334,17 @@ InitializeCurrentSetting ( FORMSET_STORAGE *Storage; FORM_BROWSER_FORMSET *OldFormSet; + // + // Try to find pre FormSet in the maintain backup list. + // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList. + // + OldFormSet = GetFormSetFromHiiHandle (FormSet->HiiHandle); + if (OldFormSet != NULL) { + RemoveEntryList (&OldFormSet->Link); + DestroyFormSet (OldFormSet); + } + InsertTailList (&gBrowserFormSetList, &FormSet->Link); + // // Extract default from IFR binary for no storage questions. // @@ -4327,17 +4361,6 @@ InitializeCurrentSetting ( Link = GetNextNode (&FormSet->StorageListHead, Link); } - - // - // Try to find pre FormSet in the maintain backup list. - // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList. - // - OldFormSet = GetFormSetFromHiiHandle (FormSet->HiiHandle); - if (OldFormSet != NULL) { - RemoveEntryList (&OldFormSet->Link); - DestroyFormSet (OldFormSet); - } - InsertTailList (&gBrowserFormSetList, &FormSet->Link); } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index bd19ae6cb7..7da21b713c 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -151,7 +151,6 @@ typedef struct { CHAR16 *ConfigRequest; // = + // includes all fields which is used by current form sets. UINTN SpareStrLen; // Spare length of ConfigRequest string buffer - UINT8 ReferenceCount; // How many form set storage refrence this storage. } BROWSER_STORAGE; #define BROWSER_STORAGE_FROM_LINK(a) CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE) -- cgit v1.2.3