summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2015-08-26 09:46:29 +0000
committerlzeng14 <lzeng14@Edk2>2015-08-26 09:46:29 +0000
commitde2d7497fd7e64f9c2647bc5f1003d5f427916db (patch)
treedf727ce615da5a4dfb263370e78c45123bd27146 /MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
parent1f70d7478699bdbcc8e54f844f55e08e904d80d6 (diff)
downloadedk2-platforms-de2d7497fd7e64f9c2647bc5f1003d5f427916db.tar.xz
MdeModulePkg FaultTolerantWrite: Error handling for erase operation failure
There may be anti-flash wear out feature to forbid erase operation after end of dxe. The code is missing some error handling for erase operation failure, it should return directly after the erase operation failed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18320 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c')
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index f3e6eac5d2..31f1e0bda6 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
@@ -2,7 +2,7 @@
Internal functions to operate Working Block Space.
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -510,6 +510,11 @@ FtwReclaimWorkSpace (
// Write the memory buffer to spare block
//
Status = FtwEraseSpareBlock (FtwDevice);
+ if (EFI_ERROR (Status)) {
+ FreePool (TempBuffer);
+ FreePool (SpareBuffer);
+ return EFI_ABORTED;
+ }
Ptr = TempBuffer;
for (Index = 0; TempBufferSize > 0; Index += 1) {
if (TempBufferSize > FtwDevice->SpareBlockSize) {
@@ -584,6 +589,10 @@ FtwReclaimWorkSpace (
// Restore spare backup buffer into spare block , if no failure happened during FtwWrite.
//
Status = FtwEraseSpareBlock (FtwDevice);
+ if (EFI_ERROR (Status)) {
+ FreePool (SpareBuffer);
+ return EFI_ABORTED;
+ }
Ptr = SpareBuffer;
for (Index = 0; Index < FtwDevice->NumberOfSpareBlock; Index += 1) {
Length = FtwDevice->SpareBlockSize;