From: Robin Murphy <robin.murphy@arm.com>
To: miles.chen@mediatek.com, Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com
Subject: Re: [PATCH] lib/dma-debug.c: fix memory leakage
Date: Thu, 22 Feb 2018 14:04:17 +0000 [thread overview]
Message-ID: <6df7e9bd-2203-0692-97e4-8c6434304b0f@arm.com> (raw)
In-Reply-To: <1519298540-3071-1-git-send-email-miles.chen@mediatek.com>
On 22/02/18 11:22, miles.chen@mediatek.com wrote:
> From: Miles Chen <miles.chen@mediatek.com>
>
> Marty reported a memory leakage introduced by commit 3aaabbf1c39e
> ("lib/dma-debug.c: fix incorrect pfn calculation"). Fix it
> by checking the virtual address before allocating the entry.
Oops, seems I failed to look closely enough at the surrounding diff
context when I reviewed the original patch... :(
> This patch also use virt_addr_valid() instead of virt_to_page()
> to check if a virtual address is linear.
That's an area I happen to have been looking at lately and now
understand a lot better, so fully agreed there as well.
Acked-by: Robin Murphy <robin.murphy@arm.com>
Maybe also worth having a proper Fixes: tag instead of just naming the
commit in prose?
Thanks,
Robin.
> Reported-by: Marty Faltesek <mfaltesek@google.com>
> Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> ---
> lib/dma-debug.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/lib/dma-debug.c b/lib/dma-debug.c
> index 1b34d210452c..7f5cdc1e6b29 100644
> --- a/lib/dma-debug.c
> +++ b/lib/dma-debug.c
> @@ -1491,12 +1491,12 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
> if (unlikely(virt == NULL))
> return;
>
> - entry = dma_entry_alloc();
> - if (!entry)
> + /* handle vmalloc and linear addresses */
> + if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt))
> return;
>
> - /* handle vmalloc and linear addresses */
> - if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
> + entry = dma_entry_alloc();
> + if (!entry)
> return;
>
> entry->type = dma_debug_coherent;
> @@ -1528,7 +1528,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size,
> };
>
> /* handle vmalloc and linear addresses */
> - if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
> + if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt))
> return;
>
> if (is_vmalloc_addr(virt))
>
next prev parent reply other threads:[~2018-02-22 14:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 11:22 miles.chen
2018-02-22 14:04 ` Robin Murphy [this message]
2018-02-22 23:03 ` Christoph Hellwig
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=6df7e9bd-2203-0692-97e4-8c6434304b0f@arm.com \
--to=robin.murphy@arm.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=miles.chen@mediatek.com \
--cc=wsd_upstream@mediatek.com \
/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
all inboxes | Powered by JetHome®