diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c index 9f372c1437..6925f3c6eb 100644 --- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c +++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c @@ -811,13 +811,6 @@ FindVariable ( VARIABLE_STORE_HEADER *VariableStoreHeader[2]; UINTN Index; - // - // We aquire the lock at the entry of FindVariable as GetVariable, GetNextVariableName - // SetVariable all call FindVariable at entry point. Please move "Aquire Lock" to - // the correct places if this assumption does not hold TRUE anymore. - // - AcquireLockOnlyAtBootTime(&Global->VariableServicesLock); - // // 0: Non-Volatile, 1: Volatile // @@ -906,6 +899,9 @@ EmuGetVariable ( if (VariableName == NULL || VendorGuid == NULL || DataSize == NULL) { return EFI_INVALID_PARAMETER; } + + AcquireLockOnlyAtBootTime(&Global->VariableServicesLock); + // // Find existing variable // @@ -979,6 +975,8 @@ EmuGetNextVariableName ( return EFI_INVALID_PARAMETER; } + AcquireLockOnlyAtBootTime(&Global->VariableServicesLock); + Status = FindVariable (VariableName, VendorGuid, &Variable, Global); if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) { @@ -1129,6 +1127,8 @@ EmuSetVariable ( } } + AcquireLockOnlyAtBootTime(&Global->VariableServicesLock); + // // Check whether the input variable is already existed //