From 6c03e3d4d36e8fb3c6eb97f973ffdbee920ca468 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Thu, 19 Jan 2012 06:46:28 +0000 Subject: Sync patch r11932 from main trunk. Fix a potential memory free failure bug in AtaAtapiPassThru. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010@12940 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c index 50b95a6713..52cc874dc4 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c @@ -1356,6 +1356,7 @@ AtaUdmaInOut ( UINT8 RegisterValue; EFI_ATA_DMA_PRD *PrdBaseAddr; + EFI_ATA_DMA_PRD *TempPrdBaseAddr; UINTN PrdTableNum; UINTN PrdTableSize; EFI_PHYSICAL_ADDRESS PrdTableMapAddr; @@ -1473,20 +1474,21 @@ AtaUdmaInOut ( // Fill the PRD table with appropriate bus master address of data buffer and data length. // ByteRemaining = ByteCount; + TempPrdBaseAddr = PrdBaseAddr; while (ByteRemaining != 0) { if (ByteRemaining <= 0x10000) { - PrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress); - PrdBaseAddr->ByteCount = (UINT16) ByteRemaining; - PrdBaseAddr->EndOfTable = 0x8000; + TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress); + TempPrdBaseAddr->ByteCount = (UINT16) ByteRemaining; + TempPrdBaseAddr->EndOfTable = 0x8000; break; } - PrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress); - PrdBaseAddr->ByteCount = (UINT16) 0x0; + TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress); + TempPrdBaseAddr->ByteCount = (UINT16) 0x0; ByteRemaining -= 0x10000; BufferMapAddress += 0x10000; - PrdBaseAddr++; + TempPrdBaseAddr++; } // -- cgit