diff options
author | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-12-17 03:18:16 +0000 |
---|---|---|
committer | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-12-17 03:18:16 +0000 |
commit | d379cbc75d55fcebfbb86921c72194bb6cb3ca6e (patch) | |
tree | 4177965da36677cacbf0c6ddc9447ddda89f05bd /MdeModulePkg/Universal | |
parent | 95830a117adb0cb6f0a78134e899e602ec99310b (diff) | |
download | edk2-platforms-d379cbc75d55fcebfbb86921c72194bb6cb3ca6e.tar.xz |
Reclaim work space when the remaining space size is even not enough to contain one header + one record.
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14005 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r-- | MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c index bbe5fb63b5..340e167ac9 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c @@ -166,6 +166,7 @@ WorkSpaceRefresh ( {
EFI_STATUS Status;
UINTN Length;
+ UINTN RemainingSpaceSize;
//
// Initialize WorkSpace as FTW_ERASED_BYTE
@@ -198,7 +199,15 @@ WorkSpaceRefresh ( FtwDevice->FtwWorkSpaceSize,
&FtwDevice->FtwLastWriteHeader
);
- if (EFI_ERROR (Status)) {
+ RemainingSpaceSize = FtwDevice->FtwWorkSpaceSize - ((UINTN) FtwDevice->FtwLastWriteHeader - (UINTN) FtwDevice->FtwWorkSpace);
+ DEBUG ((EFI_D_INFO, "Ftw: Remaining work space size - %x\n", RemainingSpaceSize));
+ //
+ // If FtwGetLastWriteHeader() returns error, or the remaining space size is even not enough to contain
+ // one EFI_FAULT_TOLERANT_WRITE_HEADER + one EFI_FAULT_TOLERANT_WRITE_RECORD(It will cause that the header
+ // pointed by FtwDevice->FtwLastWriteHeader or record pointed by FtwDevice->FtwLastWriteRecord may contain invalid data),
+ // it needs to reclaim work space.
+ //
+ if (EFI_ERROR (Status) || RemainingSpaceSize < sizeof (EFI_FAULT_TOLERANT_WRITE_HEADER) + sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD)) {
//
// reclaim work space in working block.
//
|