From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.32751.1628831112888552588 for ; Thu, 12 Aug 2021 22:05:13 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 481ED1063; Thu, 12 Aug 2021 22:05:11 -0700 (PDT) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EC8633F70D; Thu, 12 Aug 2021 22:05:10 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, Jeremy Linton Subject: [PATCH] EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field Date: Fri, 13 Aug 2021 00:05:08 -0500 Message-Id: <20210813050508.28232-1-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- 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; } =20 - if (Map->Operation =3D=3D MapOperationBusMasterRead) { + if (Operation =3D=3D MapOperationBusMasterRead) { CopyMem (Map->BufferAddress, (VOID *)(UINTN)HostAddress, *NumberOf= Bytes); } mCpu->FlushDataCache (mCpu, (UINTN)Map->BufferAddress, AllocSize, --=20 2.13.7