]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
Fix a potential memory free failure bug in AtaAtapiPassThru
[mirror_edk2.git] / 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