public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ming Huang <huangming23@huawei.com>
To: <devel@edk2.groups.io>, <jian.j.wang@intel.com>,
	<hao.a.wu@intel.com>, <liming.gao@intel.com>
Cc: <lidongzhan@huawei.com>, <huangming23@huawei.com>,
	<songdongkuang@huawei.com>, <wanghuiqiang@huawei.com>,
	<qiuliangen@huawei.com>, <shenlimei@huawei.com>
Subject: [RFC edk2 v1 1/1] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable
Date: Mon, 25 May 2020 19:34:18 +0800	[thread overview]
Message-ID: <1590406458-59742-2-git-send-email-huangming23@huawei.com> (raw)
In-Reply-To: <1590406458-59742-1-git-send-email-huangming23@huawei.com>

When occur reclaim in AutoUpdateLangVariable(), the CurrPtr of
Variable is invalid. The State will be update with wrong position
after UpdateVariable in this situation and two valid PlatformLang or
Lang variables will exist. BmForEachVariable() will enter endless loop
while exist two valid PlatformLang variables. So FindVariable() should
be invoked atfer AutoUpdateLangVariable().

https://bugzilla.tianocore.org/show_bug.cgi?id=2667

Signed-off-by: Ming Huang <huangming23@huawei.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 1e71fc6..0cec981 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2741,6 +2741,19 @@ VariableServiceSetVariable (
     mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) Point;
   }
 
+  if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {
+    //
+    // Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang.
+    //
+    Status = AutoUpdateLangVariable (VariableName, Data, DataSize);
+    if (EFI_ERROR (Status)) {
+      //
+      // The auto update operation failed, directly return to avoid inconsistency between PlatformLang and Lang.
+      //
+      goto Done;
+    }
+  }
+
   //
   // Check whether the input variable is already existed.
   //
@@ -2763,19 +2776,6 @@ VariableServiceSetVariable (
     }
   }
 
-  if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {
-    //
-    // Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang.
-    //
-    Status = AutoUpdateLangVariable (VariableName, Data, DataSize);
-    if (EFI_ERROR (Status)) {
-      //
-      // The auto update operation failed, directly return to avoid inconsistency between PlatformLang and Lang.
-      //
-      goto Done;
-    }
-  }
-
   if (mVariableModuleGlobal->VariableGlobal.AuthSupport) {
     Status = AuthVariableLibProcessVariable (VariableName, VendorGuid, Data, DataSize, Attributes);
   } else {
-- 
2.8.1


  reply	other threads:[~2020-05-25 11:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 11:34 [RFC edk2 v1 0/1] Fix a infrequent issue in variable Ming Huang
2020-05-25 11:34 ` Ming Huang [this message]
2020-05-26  0:39   ` [edk2-devel] [RFC edk2 v1 1/1] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable Guomin Jiang
2020-05-26  6:08     ` Ming Huang
2020-05-27  0:12       ` Guomin Jiang
2020-05-27 14:40         ` Ming Huang
2020-05-28  0:28           ` Guomin Jiang
2020-06-29  3:03 ` [edk2-devel] [RFC edk2 v1 0/1] Fix a infrequent issue in variable Guomin Jiang
2020-06-29  3:59   ` Ming Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1590406458-59742-2-git-send-email-huangming23@huawei.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox