[edk2-devel] [PATCH] EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field

Jeremy Linton posted 1 patch 2 years, 8 months ago
Failed in applying to current master (apply log)
EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [PATCH] EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field
Posted by Jeremy Linton 2 years, 8 months ago
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 <jeremy.linton@arm.com>
---
 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.13.7



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79240): https://edk2.groups.io/g/devel/message/79240
Mute This Topic: https://groups.io/mt/84857084/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field
Posted by Ard Biesheuvel 2 years, 8 months ago
On Fri, 13 Aug 2021 at 07:05, Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> 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 <jeremy.linton@arm.com>

Thanks for fixing this.

Liming, I am not sure what stage of the release cycle we are currently
in, but this fix should go in right away anyway. Unless any objections
are raised, I will merge it later today. I will leave it to you to
decide how this affects the stable tag release schedule.

-- 
Ard.


> ---
>  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.13.7
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79338): https://edk2.groups.io/g/devel/message/79338
Mute This Topic: https://groups.io/mt/84857084/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field
Posted by Ard Biesheuvel 2 years, 8 months ago
On Mon, 16 Aug 2021 at 09:10, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 13 Aug 2021 at 07:05, Jeremy Linton <jeremy.linton@arm.com> wrote:
> >
> > 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 <jeremy.linton@arm.com>
>
> Thanks for fixing this.
>
> Liming, I am not sure what stage of the release cycle we are currently
> in, but this fix should go in right away anyway. Unless any objections
> are raised, I will merge it later today. I will leave it to you to
> decide how this affects the stable tag release schedule.
>

Merged as #1901


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79430): https://edk2.groups.io/g/devel/message/79430
Mute This Topic: https://groups.io/mt/84857084/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-