From ef56f55d19e1b0b4ba6f9b28d73165c7f0a4627c Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Fri, 13 Aug 2021 00:05:08 -0500 Subject: [PATCH] EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field Map->Operation is used to select whether a DMA region that is being bounced has the source buffer copied to it. Except Map->Operation isn't yet set, so the behavior is somewhat random. Instead use the passed in Operation parameter. Signed-off-by: Jeremy Linton Reviewed-by: Ard Biesheuvel --- EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c b/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c index 9c8ef5bfb5..1aec86fffd 100644 --- a/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c +++ b/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c @@ -224,7 +224,7 @@ DmaMap ( goto FreeMapInfo; } - if (Map->Operation == MapOperationBusMasterRead) { + if (Operation == MapOperationBusMasterRead) { CopyMem (Map->BufferAddress, (VOID *)(UINTN)HostAddress, *NumberOfBytes); } mCpu->FlushDataCache (mCpu, (UINTN)Map->BufferAddress, AllocSize, -- 2.39.2