From e56e18704493062ef9dc3f6df25a4c02825eb611 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Fri, 10 Apr 2015 01:53:38 +0000 Subject: MdeModulePkg Variable: Enhance the code logic about VariableLock to just return EFI_SUCCESS if the variable has been in the locked list. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Liming Gao Reviewed-by: Jiewen Yao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17141 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index b3c36992e3..a4104cc228 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -2418,6 +2418,8 @@ VariableLockRequestToLock ( { VARIABLE_ENTRY *Entry; CHAR16 *Name; + LIST_ENTRY *Link; + VARIABLE_ENTRY *LockedEntry; if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) { return EFI_INVALID_PARAMETER; @@ -2436,11 +2438,23 @@ VariableLockRequestToLock ( AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock); + for ( Link = GetFirstNode (&mLockedVariableList) + ; !IsNull (&mLockedVariableList, Link) + ; Link = GetNextNode (&mLockedVariableList, Link) + ) { + LockedEntry = BASE_CR (Link, VARIABLE_ENTRY, Link); + Name = (CHAR16 *) ((UINTN) LockedEntry + sizeof (*LockedEntry)); + if (CompareGuid (&LockedEntry->Guid, VendorGuid) && (StrCmp (Name, VariableName) == 0)) { + goto Done; + } + } + Name = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry)); StrnCpy (Name, VariableName, StrLen (VariableName)); CopyGuid (&Entry->Guid, VendorGuid); InsertTailList (&mLockedVariableList, &Entry->Link); +Done: ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock); return EFI_SUCCESS; -- cgit v1.2.3