]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg VariablePei: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL
authorMichael Kubacki <michael.kubacki@microsoft.com>
Fri, 27 Mar 2020 21:55:35 +0000 (05:55 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 7 Apr 2020 13:51:24 +0000 (13:51 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062

This commit makes the behavior for PeiGetVariable() match the following
specification-defined behavior. It is now consistent with the DXE/SMM
variable driver implementation.

The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()"
"Attributes" parameter description states:

"If not NULL, a pointer to the memory location to return the
 attributes bitmask for the variable. See 'Related Definitions.'
 If not NULL, then Attributes is set on output both when
 EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned."

The attributes were previously only returned from the implementation
in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or
EFI_BUFFER_TOO_SMALL according to spec.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>
MdeModulePkg/Universal/Variable/Pei/Variable.c

index f61465fc30456e9ddd321eeae39cec46416dd67a..f420b58165b7864dbb9f15ee500e2eb7afe87705 100644 (file)
@@ -3,6 +3,7 @@
   PEI ReadOnly Varaiable2 PPI. These services operates the non volatile storage space.\r
 \r
 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -1047,17 +1048,17 @@ PeiGetVariable (
     }\r
 \r
     GetVariableNameOrData (&StoreInfo, GetVariableDataPtr (Variable.CurrPtr, VariableHeader, StoreInfo.AuthFlag), VarDataSize, Data);\r
-\r
-    if (Attributes != NULL) {\r
-      *Attributes = VariableHeader->Attributes;\r
-    }\r
-\r
-    *DataSize = VarDataSize;\r
-    return EFI_SUCCESS;\r
+    Status = EFI_SUCCESS;\r
   } else {\r
-    *DataSize = VarDataSize;\r
-    return EFI_BUFFER_TOO_SMALL;\r
+    Status = EFI_BUFFER_TOO_SMALL;\r
   }\r
+\r
+  if (Attributes != NULL) {\r
+    *Attributes = VariableHeader->Attributes;\r
+  }\r
+  *DataSize = VarDataSize;\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r