From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from huawei.com (huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web11.29557.1590406596321143176 for ; Mon, 25 May 2020 04:36:36 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.32, mailfrom: huangming23@huawei.com) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 44BD010F9364AA6BCBC0 for ; Mon, 25 May 2020 19:36:32 +0800 (CST) Received: from HGH1000039998.huawei.com (10.184.68.188) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Mon, 25 May 2020 19:36:25 +0800 From: Ming Huang To: , , , CC: , , , , , Subject: [RFC edk2 v1 1/1] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable Date: Mon, 25 May 2020 19:34:18 +0800 Message-ID: <1590406458-59742-2-git-send-email-huangming23@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1590406458-59742-1-git-send-email-huangming23@huawei.com> References: <1590406458-59742-1-git-send-email-huangming23@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.68.188] X-CFilter-Loop: Reflected Content-Type: text/plain 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 --- 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