On 22 September 2016 at 23:37, Daniil Egranov <daniil.egra...@arm.com> wrote: > The patch is fixing memory leak in case of errors. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Daniil Egranov <daniil.egra...@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheu...@linaro.org> > --- > ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > index d48d6ff..e0006c0 100644 > --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c > @@ -90,14 +90,13 @@ DmaMap ( > return EFI_OUT_OF_RESOURCES; > } > > - *Mapping = Map; > - > if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) || > ((*NumberOfBytes & (gCacheAlignment - 1)) != 0)) { > > // Get the cacheability of the region > Status = gDS->GetMemorySpaceDescriptor (*DeviceAddress, &GcdDescriptor); > if (EFI_ERROR(Status)) { > + FreePool(Map); > return Status; > } > > @@ -112,6 +111,7 @@ DmaMap ( > "%a: Operation type 'MapOperationBusMasterCommonBuffer' is only > supported\n" > "on memory regions that were allocated using DmaAllocateBuffer > ()\n", > __FUNCTION__)); > + FreePool(Map); > return EFI_UNSUPPORTED; > } > > @@ -122,6 +122,7 @@ DmaMap ( > Map->DoubleBuffer = TRUE; > Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES > (*NumberOfBytes), &Buffer); > if (EFI_ERROR (Status)) { > + FreePool(Map); > return Status; > } > > @@ -162,6 +163,8 @@ DmaMap ( > Map->NumberOfBytes = *NumberOfBytes; > Map->Operation = Operation; > > + *Mapping = Map; > + > return EFI_SUCCESS; > } > > -- > 2.7.4 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel