From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Sergei Shtylyov
<sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Cc: Laxman Dewangan
<ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Dan Williams
<dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] dmaengine: tegra210-adma: fix of_irq_get() error check
Date: Mon, 31 Jul 2017 18:56:16 +0200 [thread overview]
Message-ID: <20170731165616.GC27815@ulmo> (raw)
In-Reply-To: <49996233-5ccd-58e6-db00-b5d402ff6e74-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2520 bytes --]
On Mon, Jul 31, 2017 at 03:59:35PM +0300, Sergei Shtylyov wrote:
> On 07/31/2017 12:57 PM, Sergei Shtylyov wrote:
>
> > > > of_irq_get() may return 0 as well as negative error number on failure,
> > > > while the driver only checks for the negative values. The driver would then
> > > > call request_irq(0, ...) in tegra_adma_alloc_chan_resources() and never get
> > > > valid channel interrupt.
> > > >
> > > > Check for 'tdc->irq <= 0' instead and return -ENXIO from the driver's probe
> > > > iff of_irq_get() returned 0.
> > > >
> > > > Fixes: f46b195799b5 ("dmaengine: tegra-adma: Add support for Tegra210 ADMA")
> > > > Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
> [...]
>
> > > > Index: slave-dma/drivers/dma/tegra210-adma.c
> > > > ===================================================================
> > > > --- slave-dma.orig/drivers/dma/tegra210-adma.c
> > > > +++ slave-dma/drivers/dma/tegra210-adma.c
> > > > @@ -717,8 +717,8 @@ static int tegra_adma_probe(struct platf
> > > > tdc->chan_addr = tdma->base_addr + ADMA_CH_REG_OFFSET(i);
> > > > tdc->irq = of_irq_get(pdev->dev.of_node, i);
> > > > - if (tdc->irq < 0) {
> > > > - ret = tdc->irq;
> > > > + if (tdc->irq <= 0) {
> > > > + ret = tdc->irq ?: -ENXIO;
> > > > goto irq_dispose;
> > > > }
> > > >
> > >
> > > I think in this particular case it would be better to just call
> > > platform_get_irq(), which already implements the equivalent.
>
> Not that platform_get_irq() was no better (if not worse indeed, as it
> could return 0 both on failure ad success), until I fixed it back in 2016:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af
>
> >
> > OK, I'll try looking into that...
>
> I've looked at the commit history and no, I don't agree to use
> platform_get_irq(): my platform_get_irq() fix landed in mainline later than
> this driver, so fixing this bug in stable kernels would ensue an extra
> dependency...
Well, surely the platform_get_irq() function should also be fixed in
stable kernels, so that all callers can be fixed at the same time.
That said, this does fix a bug, and it fixes it in the least invasive
way, and the damage I'm complaining about is preexisting, so:
Acked-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-07-31 16:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-30 18:10 [PATCH] dmaengine: tegra210-adma: fix of_irq_get() error check Sergei Shtylyov
[not found] ` <20170730181051.733168837-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-07-30 19:46 ` Sergei Shtylyov
2017-07-31 9:30 ` Thierry Reding
2017-07-31 9:57 ` Sergei Shtylyov
[not found] ` <0102e75c-d1be-e274-808b-f9d3f434924d-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-07-31 12:59 ` Sergei Shtylyov
[not found] ` <49996233-5ccd-58e6-db00-b5d402ff6e74-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-07-31 16:56 ` Thierry Reding [this message]
2017-07-31 17:07 ` Sergei Shtylyov
2017-07-31 20:11 ` Jon Hunter
2017-08-09 6:10 ` Vinod Koul
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=20170731165616.GC27815@ulmo \
--to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org \
--cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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