From: Sergei Shtylyov Subject: Re: [PATCH] dmaengine: tegra210-adma: fix of_irq_get() error check Date: Mon, 31 Jul 2017 15:59:35 +0300 Message-ID: <49996233-5ccd-58e6-db00-b5d402ff6e74@cogentembedded.com> References: <20170730181051.733168837@cogentembedded.com> <20170731093057.GA26667@ulmo> <0102e75c-d1be-e274-808b-f9d3f434924d@cogentembedded.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <0102e75c-d1be-e274-808b-f9d3f434924d-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org> Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Thierry Reding Cc: Laxman Dewangan , Jon Hunter , Vinod Koul , dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Dan Williams List-Id: linux-tegra@vger.kernel.org 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 [...] >>> 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... >> Thierry MBR, Sergei