]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
MdeModulePkg Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableSmmRuntimeDxe.c
index 2cf0ed32ae55bea2094e7bb578a60810c242dbc1..ca833fb0244d1b62f10caaf939f932af5766b678 100644 (file)
@@ -14,6 +14,7 @@
   InitCommunicateBuffer() is really function to check the variable data size.\r
 \r
 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -642,10 +643,6 @@ FindVariableInRuntimeCache (
         }\r
 \r
         CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr, mVariableAuthFormat), TempDataSize);\r
-        if (Attributes != NULL) {\r
-          *Attributes = RtPtrTrack.CurrPtr->Attributes;\r
-        }\r
-\r
         *DataSize = TempDataSize;\r
 \r
         UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE, FALSE, FALSE, TRUE, &mVariableInfo);\r
@@ -661,6 +658,11 @@ FindVariableInRuntimeCache (
   }\r
 \r
 Done:\r
+  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {\r
+    if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) {\r
+      *Attributes = RtPtrTrack.CurrPtr->Attributes;\r
+    }\r
+  }\r
   mVariableRuntimeCacheReadLock = FALSE;\r
 \r
   return Status;\r