public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ming Huang" <ming.huang-@outlook.com>
To: devel@edk2.groups.io, hao.a.wu@intel.com, liming.gao@intel.com,
	edk2-devel@lists.01.org
Cc: phoenix.liyi@huawei.com, songdongkuang@huawei.com,
	huangming23@huawei.com, shenlimei@huawei.com,
	wanghuiqiang@huawei.com, Ming Huang <ming.huang-@outlook.com>
Subject: [PATCH v1 2/2] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable
Date: Wed,  4 Mar 2020 10:48:52 +0800	[thread overview]
Message-ID: <HK0PR02MB2593926E8F3512B597C7988DA7E50@HK0PR02MB2593.apcprd02.prod.outlook.com> (raw)
In-Reply-To: <20200304024852.30669-1-ming.huang-@outlook.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().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <ming.huang-@outlook.com>
---
 .../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 40efa10839ad..9a20be3e581f 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2735,6 +2735,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.
   //
@@ -2757,19 +2770,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.9.5


      parent reply	other threads:[~2020-03-04  2:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200304024852.30669-1-ming.huang-@outlook.com>
2020-03-04  2:48 ` [PATCH v1 1/2] MdeModulePkg/Variable: Remove some debug print for runtime Ming Huang
2020-03-04  2:48 ` Ming Huang [this message]

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=HK0PR02MB2593926E8F3512B597C7988DA7E50@HK0PR02MB2593.apcprd02.prod.outlook.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