]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
MdeModulePkg/Variable: Make only EFI_VARIABLE_NON_VOLATILE invalid
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / Variable.c
index 9722a944201865d56dd3af20788f5dfe727821e1..6c1a3440ac8cf5abe085e451fe15d857f25db3f4 100644 (file)
@@ -19,6 +19,7 @@
 Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>\r
 Copyright (c) Microsoft Corporation.<BR>\r
+Copyright (c) 2022, ARM Limited. All rights reserved.<BR>\r
 \r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -2660,14 +2661,22 @@ VariableServiceSetVariable (
   }\r
 \r
   //\r
-  //  Make sure if runtime bit is set, boot service bit is set also.\r
+  // Check if the combination of attribute bits is valid.\r
   //\r
   if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
+    //\r
+    // Make sure if runtime bit is set, boot service bit is set also.\r
+    //\r
     if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
       return EFI_UNSUPPORTED;\r
     } else {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
+  } else if ((Attributes & EFI_VARIABLE_ATTRIBUTES_MASK) == EFI_VARIABLE_NON_VOLATILE) {\r
+    //\r
+    // Only EFI_VARIABLE_NON_VOLATILE attribute is invalid\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
   } else if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {\r
     if (!mVariableModuleGlobal->VariableGlobal.AuthSupport) {\r
       //\r
@@ -3142,6 +3151,11 @@ VariableServiceQueryVariableInfo (
     // Make sure the Attributes combination is supported by the platform.\r
     //\r
     return EFI_UNSUPPORTED;\r
+  } else if ((Attributes & EFI_VARIABLE_ATTRIBUTES_MASK) == EFI_VARIABLE_NON_VOLATILE) {\r
+    //\r
+    // Only EFI_VARIABLE_NON_VOLATILE attribute is invalid\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
   } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
     //\r
     // Make sure if runtime bit is set, boot service bit is set also.\r