diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index d23aea4bc7..1e71fc642c 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -18,6 +18,8 @@ Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
+Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -2379,9 +2381,6 @@ VariableServiceGetVariable ( } CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr, mVariableModuleGlobal->VariableGlobal.AuthFormat), VarDataSize); - if (Attributes != NULL) { - *Attributes = Variable.CurrPtr->Attributes; - } *DataSize = VarDataSize; UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE, &gVariableInfo); @@ -2395,6 +2394,11 @@ VariableServiceGetVariable ( } Done: + if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) { + if (Attributes != NULL && Variable.CurrPtr != NULL) { + *Attributes = Variable.CurrPtr->Attributes; + } + } ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock); return Status; } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 2cf0ed32ae..ca833fb024 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -14,6 +14,7 @@ InitCommunicateBuffer() is really function to check the variable data size. Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -642,10 +643,6 @@ FindVariableInRuntimeCache ( } CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr, mVariableAuthFormat), TempDataSize); - if (Attributes != NULL) { - *Attributes = RtPtrTrack.CurrPtr->Attributes; - } - *DataSize = TempDataSize; UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE, FALSE, FALSE, TRUE, &mVariableInfo); @@ -661,6 +658,11 @@ FindVariableInRuntimeCache ( } Done: + if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) { + if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) { + *Attributes = RtPtrTrack.CurrPtr->Attributes; + } + } mVariableRuntimeCacheReadLock = FALSE; return Status;