From: mina86@mina86.com (Michal Nazarewicz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drivers: dma-coherent: free memory when failed to init DMA memory pool
Date: Thu, 03 Dec 2015 13:50:55 +0100 [thread overview]
Message-ID: <xa1toae7y9u8.fsf@mina86.com> (raw)
In-Reply-To: <1449138962-8264-1-git-send-email-b38611@freescale.com>
On Thu, Dec 03 2015, Fugang Duan wrote:
> Free dma coherent memory when it failed to init DMA memory pool after
> calling .dma_init_coherent_memory(), otherwise it causes memmory leak.
>
> Signed-off-by: Fugang Duan <B38611@freescale.com>
> ---
> drivers/base/dma-coherent.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
> index 55b8398..beb6bbe 100644
> --- a/drivers/base/dma-coherent.c
> +++ b/drivers/base/dma-coherent.c
> @@ -286,6 +286,7 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
> &mem) != DMA_MEMORY_MAP) {
> pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",
> &rmem->base, (unsigned long)rmem->size / SZ_1M);
> + kfree(mem);
mem == NULL at this point. If dma_init_coherent_memory doesn?t return
DMA_MEMORY_MAP, mem pointer is not assigned any value. If you think
there is a memory leak, please demonstrate a path of it happening.
> return -ENODEV;
> }
> rmem->priv = mem;
> --
> 1.9.1
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, ??? ?mina86? ?????? (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
next prev parent reply other threads:[~2015-12-03 12:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 10:36 [PATCH] drivers: dma-coherent: free memory when failed to init DMA memory pool Fugang Duan
2015-12-03 12:50 ` Michal Nazarewicz [this message]
2015-12-03 13:54 ` Duan Andy
2015-12-03 14:32 ` Michal Nazarewicz
2015-12-03 15:39 ` Russell King - ARM Linux
2015-12-03 16:22 ` Michal Nazarewicz
2015-12-04 2:18 ` Duan Andy
2015-12-04 2:20 ` Duan Andy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xa1toae7y9u8.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).