Fix a potential memory free failure bug in AtaAtapiPassThru

Signed-off-by: erictian
Reviewed-by: rsun3

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11932 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
erictian 2011-06-30 03:32:00 +00:00
parent cf40a2bf8b
commit 2525e22198
1 changed files with 9 additions and 7 deletions

View File

@ -1470,6 +1470,7 @@ AtaUdmaInOut (
EFI_PHYSICAL_ADDRESS PrdTableMapAddr; EFI_PHYSICAL_ADDRESS PrdTableMapAddr;
VOID *PrdTableMap; VOID *PrdTableMap;
EFI_ATA_DMA_PRD *PrdBaseAddr; EFI_ATA_DMA_PRD *PrdBaseAddr;
EFI_ATA_DMA_PRD *TempPrdBaseAddr;
UINTN PrdTableNum; UINTN PrdTableNum;
UINT8 RegisterValue; UINT8 RegisterValue;
@ -1618,21 +1619,22 @@ AtaUdmaInOut (
// //
// Fill the PRD table with appropriate bus master address of data buffer and data length. // Fill the PRD table with appropriate bus master address of data buffer and data length.
// //
ByteRemaining = ByteCount; ByteRemaining = ByteCount;
TempPrdBaseAddr = PrdBaseAddr;
while (ByteRemaining != 0) { while (ByteRemaining != 0) {
if (ByteRemaining <= 0x10000) { if (ByteRemaining <= 0x10000) {
PrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress); TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress);
PrdBaseAddr->ByteCount = (UINT16) ByteRemaining; TempPrdBaseAddr->ByteCount = (UINT16) ByteRemaining;
PrdBaseAddr->EndOfTable = 0x8000; TempPrdBaseAddr->EndOfTable = 0x8000;
break; break;
} }
PrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress); TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress);
PrdBaseAddr->ByteCount = (UINT16) 0x0; TempPrdBaseAddr->ByteCount = (UINT16) 0x0;
ByteRemaining -= 0x10000; ByteRemaining -= 0x10000;
BufferMapAddress += 0x10000; BufferMapAddress += 0x10000;
PrdBaseAddr++; TempPrdBaseAddr++;
} }
// //