X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FFaultTolerantWriteDxe%2FFtwMisc.c;h=f1d64942b47c294cfad2fe5ad19e55f85ccaeced;hb=7ea4cf3f595f35373ff57cff997cde0bcea6871f;hp=dc110a226d9eeb5bd8be9decd5280a6594b34b87;hpb=32732a333ae22cc0283c09df947d7b8bad50144e;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c index dc110a226d..f1d64942b4 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c @@ -2,7 +2,7 @@ Internal generic functions to operate flash block. -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
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 @@ -572,6 +572,9 @@ FlushSpareBlockToWorkingBlock ( if (Buffer == NULL) { return EFI_OUT_OF_RESOURCES; } + + WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba; + // // To guarantee that the WorkingBlockValid is set on spare block // @@ -581,7 +584,7 @@ FlushSpareBlockToWorkingBlock ( // FtwUpdateFvState ( FtwDevice->FtwBackupFvb, - FtwDevice->FtwWorkSpaceLba, + FtwDevice->FtwSpareLba + WorkSpaceLbaOffset, FtwDevice->FtwWorkSpaceBase + sizeof (EFI_GUID) + sizeof (UINT32), WORKING_BLOCK_VALID ); @@ -608,7 +611,6 @@ FlushSpareBlockToWorkingBlock ( // // Clear the CRC and STATE, copy data from spare to working block. // - WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba; WorkingBlockHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) (Buffer + (UINTN) WorkSpaceLbaOffset * FtwDevice->BlockSize + FtwDevice->FtwWorkSpaceBase); InitWorkSpaceHeader (WorkingBlockHeader); WorkingBlockHeader->WorkingBlockValid = FTW_ERASE_POLARITY; @@ -777,7 +779,7 @@ FtwGetLastWriteHeader ( // // If Offset exceed the FTW work space boudary, return error. // - if (Offset > FtwWorkSpaceSize) { + if (Offset >= FtwWorkSpaceSize) { *FtwWriteHeader = FtwHeader; return EFI_ABORTED; }