]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Variable/RuntimeDxe: Fix return status from Reclaim()
authorMichael D Kinney <michael.d.kinney@intel.com>
Fri, 10 Jul 2020 02:41:15 +0000 (19:41 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 14 Jul 2020 16:38:30 +0000 (16:38 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2844

Update Reclaim() to return the error status from the reclaim
operation and not the status of SynchronizeRuntimeVariableCache()
that can be EFI_SUCCESS even through the status from reclaim
is an error.  Without this change, the return status from
SetVariable() can be EFI_SUCCESS even though the variable was
not actually set.  This occurs if the variable store is full
and a Reclaim() is invoked to free up space and even after all
possible space is freed, there is still not enough room for
the variable being set.  This condition should return
EFI_OUT_OF_RESOURCES.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

index 1e71fc642c763571a493ca0cd28e73f6ed5c6186..41f8ff4ceb6c7d5ece192ef24f425d112e0cad7a 100644 (file)
@@ -531,6 +531,7 @@ Reclaim (
   VOID                  *Point1;\r
   BOOLEAN               FoundAdded;\r
   EFI_STATUS            Status;\r
+  EFI_STATUS            DoneStatus;\r
   UINTN                 CommonVariableTotalSize;\r
   UINTN                 CommonUserVariableTotalSize;\r
   UINTN                 HwErrVariableTotalSize;\r
@@ -774,25 +775,30 @@ Reclaim (
   }\r
 \r
 Done:\r
+  DoneStatus = EFI_SUCCESS;\r
   if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) {\r
-    Status =  SynchronizeRuntimeVariableCache (\r
-                &mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCache,\r
-                0,\r
-                VariableStoreHeader->Size\r
-                );\r
-    ASSERT_EFI_ERROR (Status);\r
+    DoneStatus = SynchronizeRuntimeVariableCache (\r
+                   &mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCache,\r
+                   0,\r
+                   VariableStoreHeader->Size\r
+                   );\r
+    ASSERT_EFI_ERROR (DoneStatus);\r
     FreePool (ValidBuffer);\r
   } else {\r
     //\r
     // For NV variable reclaim, we use mNvVariableCache as the buffer, so copy the data back.\r
     //\r
     CopyMem (mNvVariableCache, (UINT8 *) (UINTN) VariableBase, VariableStoreHeader->Size);\r
-    Status =  SynchronizeRuntimeVariableCache (\r
-                &mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache,\r
-                0,\r
-                VariableStoreHeader->Size\r
-                );\r
-    ASSERT_EFI_ERROR (Status);\r
+    DoneStatus = SynchronizeRuntimeVariableCache (\r
+                   &mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache,\r
+                   0,\r
+                   VariableStoreHeader->Size\r
+                   );\r
+    ASSERT_EFI_ERROR (DoneStatus);\r
+  }\r
+\r
+  if (!EFI_ERROR (Status) && EFI_ERROR (DoneStatus)) {\r
+    Status = DoneStatus;\r
   }\r
 \r
   return Status;\r