From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x229.google.com (mail-io0-x229.google.com [IPv6:2607:f8b0:4001:c06::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1739C1A20B4 for ; Fri, 23 Sep 2016 01:00:18 -0700 (PDT) Received: by mail-io0-x229.google.com with SMTP id r145so110791561ior.0 for ; Fri, 23 Sep 2016 01:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sFOOUQS7YnxwGdOpMb1vSJWoYKMcDZusfCWXS8OHHKU=; b=TZa9XO3is6XtTNrLlJbqrsKQj0XXYihnk83DfQQPJgJG3Hhsz5pnH22JkO/0Q0W+f1 fAE/6WzZBNlGj+T/OxlfTZiH9Nla3+XuPJi1/nhqBO6sgMOig/pze90HikQQnXwCS6B1 sDA4kl4E6E+hp/SG/NJ1dgiAln5nhW+hjWr0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sFOOUQS7YnxwGdOpMb1vSJWoYKMcDZusfCWXS8OHHKU=; b=ZiW5Kx+9nalivm80zsdqMw59dhHOcAPxjchZPFRqoUfkJIZywH3tyLspBQl0Vdwfbj SaZedXeTRxpoVt+DQMZU87ow89lQZFUmb1V1BKq66mCFoCuY6ZeGmYUi63xdvLyPUzmn UD5nZMgNGwncrplFXQs3096Kqeef1/P0G1jSgOT0YUOS2+wn1FwY3xx6Lpefw58mkKY+ VBhZM3AsCQ5+qrajndDN0FFTXYYLeulZsEuyHuJst236XEhEvopZWG1G4dxr5pigOXdC uH15UHZqUBXXW9Z3Qp38HXJrzfHqAlKFfhgwGuHuXynm1zEdLYMvx6Or1tIxXQuoB8QP aMNQ== X-Gm-Message-State: AE9vXwOfDoh/WSg4vcLHBxVIrygRjnprzm6YEFqqhi4gAV1UTarUiyAXsRc4vagUqF8YrDfHVfCjCE68rt6KsL7s X-Received: by 10.107.16.29 with SMTP id y29mr7391678ioi.143.1474617617425; Fri, 23 Sep 2016 01:00:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.204.195 with HTTP; Fri, 23 Sep 2016 01:00:16 -0700 (PDT) In-Reply-To: <1474583868-41777-1-git-send-email-daniil.egranov@arm.com> References: <1474583868-41777-1-git-send-email-daniil.egranov@arm.com> From: Ard Biesheuvel Date: Fri, 23 Sep 2016 09:00:16 +0100 Message-ID: To: Daniil Egranov Cc: "edk2-devel@lists.01.org" , Leif Lindholm Subject: Re: [PATCH] ArmPkg/Library/ArmDmaLib: Deallocate Map buffer in case of error X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2016 08:00:18 -0000 Content-Type: text/plain; charset=UTF-8 On 22 September 2016 at 23:37, Daniil Egranov wrote: > The patch is fixing memory leak in case of errors. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Daniil Egranov Reviewed-by: Ard Biesheuvel > --- > 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