From: Catalin Marinas <catalin.marinas@arm.com>
To: Olav Haugan <ohaugan@codeaurora.org>
Cc: robin.murphy@arm.com, will.deacon@arm.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64/dma-mapping: Fix null-pointer check
Date: Tue, 13 Jun 2017 10:03:28 +0100 [thread overview]
Message-ID: <20170613090328.GA3302@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <20170612205028.y7a652hd46dakxdu@codeaurora.org>
On Mon, Jun 12, 2017 at 01:50:28PM -0700, Olav Haugan wrote:
> On 17-06-12 13:29:04, Catalin Marinas wrote:
> > On Sat, Jun 10, 2017 at 12:41:10PM -0700, Olav Haugan wrote:
> > > @@ -149,6 +140,11 @@ static void *__dma_alloc(struct device *dev, size_t size,
> > > bool coherent = is_device_dma_coherent(dev);
> > > pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, false);
> > >
> > > + if (!dev) {
> > > + WARN_ONCE(1, "Use an actual device structure for DMA allocation\n");
> > > + return NULL;
> > > + }
> > > +
> > > size = PAGE_ALIGN(size);
> > >
> > > if (!coherent && !gfpflags_allow_blocking(flags)) {
> > > @@ -192,8 +188,13 @@ static void __dma_free(struct device *dev, size_t size,
> > > void *vaddr, dma_addr_t dma_handle,
> > > unsigned long attrs)
> > > {
> > > - void *swiotlb_addr = phys_to_virt(dma_to_phys(dev, dma_handle));
> > > + void *swiotlb_addr;
> > >
> > > + if (!dev) {
> > > + WARN_ONCE(1, "Use an actual device structure for DMA free\n");
> > > + return;
> > > + }
> > > + swiotlb_addr = phys_to_virt(dma_to_phys(dev, dma_handle));
> >
> > I don't think we need the checks anymore. With commit 1dccb598df54
> > ("arm64: simplify dma_get_ops") __generic_dma_ops() returns
> > dummy_dma_ops when dev == NULL, so the above __dma_alloc/__dma_free
> > functions would not be called.
>
> We don't need the check in is_device_dma_coherent() either then right?
Right. The only user of this function outside
arch/arm64/mm/dma-mapping.c is Xen (shared with arm32 under
arch/arm/xen/) but since arm32 doesn't do this NULL check either, we
should be fine.
--
Catalin
prev parent reply other threads:[~2017-06-13 9:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-10 19:41 Olav Haugan
2017-06-10 22:03 ` Russell King - ARM Linux
2017-06-12 20:36 ` Olav Haugan
2017-06-12 12:29 ` Catalin Marinas
2017-06-12 20:33 ` Olav Haugan
2017-06-12 20:50 ` Olav Haugan
2017-06-13 9:03 ` Catalin Marinas [this message]
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=20170613090328.GA3302@e104818-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ohaugan@codeaurora.org \
--cc=robin.murphy@arm.com \
--cc=will.deacon@arm.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®