]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/NonCoherentDmaLib: avoid dereferencing bogus buffer address
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Wed, 17 Jun 2020 15:32:16 +0000 (17:32 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 17 Jun 2020 18:28:29 +0000 (18:28 +0000)
The bounce buffering code in NonCoherentDmaLib copies data into the
bounce buffer using CopyMem(), but passes Map->HostAddress as the
source of the copy before it has been assigned its correct value.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c

index 1153457654350c4fdf33650aa81887a23ee0f4ee..9c8ef5bfb533b1d4c480b4c4cfd3fe50a27bd936 100644 (file)
@@ -225,8 +225,7 @@ DmaMap (
     }\r
 \r
     if (Map->Operation == MapOperationBusMasterRead) {\r
-      CopyMem (Map->BufferAddress, (VOID *)(UINTN)Map->HostAddress,\r
-        *NumberOfBytes);\r
+      CopyMem (Map->BufferAddress, (VOID *)(UINTN)HostAddress, *NumberOfBytes);\r
     }\r
     mCpu->FlushDataCache (mCpu, (UINTN)Map->BufferAddress, AllocSize,\r
             EfiCpuFlushTypeWriteBack);\r