]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix a potential memory free failure bug in AtaAtapiPassThru
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 30 Jun 2011 03:32:00 +0000 (03:32 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 30 Jun 2011 03:32:00 +0000 (03:32 +0000)
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

MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c

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