Message ID | 1461077734-4327-1-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | Accepted |
Commit | e55f8c73b6255b353c021ab59017a364dd527a86 |
Headers | show |
On Tue, Apr 19, 2016 at 04:55:30PM +0200, Ard Biesheuvel wrote: > The allocation function UncachedAllocatePages () may return NULL, in > which case our implementation of DmaAllocateBuffer () should return > EFI_OUT_OF_RESOURCES rather than silently ignoring the NULL value and > returning EFI_SUCCESS. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> A clear fix which could go in separate from the rest of the series. Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> > --- > ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > index 54a49a18d302..1e6b288b10b9 100644 > --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > @@ -216,6 +216,8 @@ DmaAllocateBuffer ( > OUT VOID **HostAddress > ) > { > + VOID *Allocation; > + > if (HostAddress == NULL) { > return EFI_INVALID_PARAMETER; > } > @@ -226,13 +228,19 @@ DmaAllocateBuffer ( > // We used uncached memory to keep coherency > // > if (MemoryType == EfiBootServicesData) { > - *HostAddress = UncachedAllocatePages (Pages); > + Allocation = UncachedAllocatePages (Pages); > } else if (MemoryType == EfiRuntimeServicesData) { > - *HostAddress = UncachedAllocateRuntimePages (Pages); > + Allocation = UncachedAllocateRuntimePages (Pages); > } else { > return EFI_INVALID_PARAMETER; > } > > + if (Allocation == NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + *HostAddress = Allocation; > + > return EFI_SUCCESS; > } > > -- > 2.5.0 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c index 54a49a18d302..1e6b288b10b9 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -216,6 +216,8 @@ DmaAllocateBuffer ( OUT VOID **HostAddress ) { + VOID *Allocation; + if (HostAddress == NULL) { return EFI_INVALID_PARAMETER; } @@ -226,13 +228,19 @@ DmaAllocateBuffer ( // We used uncached memory to keep coherency // if (MemoryType == EfiBootServicesData) { - *HostAddress = UncachedAllocatePages (Pages); + Allocation = UncachedAllocatePages (Pages); } else if (MemoryType == EfiRuntimeServicesData) { - *HostAddress = UncachedAllocateRuntimePages (Pages); + Allocation = UncachedAllocateRuntimePages (Pages); } else { return EFI_INVALID_PARAMETER; } + if (Allocation == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *HostAddress = Allocation; + return EFI_SUCCESS; }
The allocation function UncachedAllocatePages () may return NULL, in which case our implementation of DmaAllocateBuffer () should return EFI_OUT_OF_RESOURCES rather than silently ignoring the NULL value and returning EFI_SUCCESS. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel