diff mbox

mtd: nand: lpc32xx: fix invalid error handling of a requested irq

Message ID 20161205014710.2015-1-vz@mleia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vladimir Zapolskiy Dec. 5, 2016, 1:47 a.m. UTC
Semantics of NR_IRQS is different on machines with SPARSE_IRQ option
disabled or enabled, in the latter case IRQs are allocated starting
at least from the value specified by NR_IRQS and going upwards, so
the check of (irq >= NR_IRQ) to decide about an error code returned by
platform_get_irq() is completely invalid, don't attempt to overrule
irq subsystem in the driver.

The change fixes LPC32xx NAND MLC driver initialization on boot.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 drivers/mtd/nand/lpc32xx_mlc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sylvain Lemieux Dec. 7, 2016, 6:09 p.m. UTC | #1
On Mon, 2016-12-05 at 03:47 +0200, Vladimir Zapolskiy wrote:
> Semantics of NR_IRQS is different on machines with SPARSE_IRQ option
> disabled or enabled, in the latter case IRQs are allocated starting
> at least from the value specified by NR_IRQS and going upwards, so
> the check of (irq >= NR_IRQ) to decide about an error code returned by
> platform_get_irq() is completely invalid, don't attempt to overrule
> irq subsystem in the driver.
> 
> The change fixes LPC32xx NAND MLC driver initialization on boot.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
>  drivers/mtd/nand/lpc32xx_mlc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Acked-by: Sylvain Lemieux <slemieux.tyco@gmail.com>
Boris BREZILLON Jan. 3, 2017, 9:12 a.m. UTC | #2
Hi Vladimir

On Mon,  5 Dec 2016 03:47:10 +0200
Vladimir Zapolskiy <vz@mleia.com> wrote:

> Semantics of NR_IRQS is different on machines with SPARSE_IRQ option
> disabled or enabled, in the latter case IRQs are allocated starting
> at least from the value specified by NR_IRQS and going upwards, so
> the check of (irq >= NR_IRQ) to decide about an error code returned by
> platform_get_irq() is completely invalid, don't attempt to overrule
> irq subsystem in the driver.
> 
> The change fixes LPC32xx NAND MLC driver initialization on boot.

Do you need to backport this fix to stable releases? If that's the
case, I'll add the Cc: stable tag when applying.

Thanks,

Boris

> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
>  drivers/mtd/nand/lpc32xx_mlc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
> index 8523881..bc6e49a 100644
> --- a/drivers/mtd/nand/lpc32xx_mlc.c
> +++ b/drivers/mtd/nand/lpc32xx_mlc.c
> @@ -776,7 +776,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
>  	init_completion(&host->comp_controller);
>  
>  	host->irq = platform_get_irq(pdev, 0);
> -	if ((host->irq < 0) || (host->irq >= NR_IRQS)) {
> +	if (host->irq < 0) {
>  		dev_err(&pdev->dev, "failed to get platform irq\n");
>  		res = -EINVAL;
>  		goto err_exit3;
Vladimir Zapolskiy Jan. 3, 2017, 10:16 a.m. UTC | #3
Hi Boris,

On 01/03/2017 11:12 AM, Boris Brezillon wrote:
> Hi Vladimir
> 
> On Mon,  5 Dec 2016 03:47:10 +0200
> Vladimir Zapolskiy <vz@mleia.com> wrote:
> 
>> Semantics of NR_IRQS is different on machines with SPARSE_IRQ option
>> disabled or enabled, in the latter case IRQs are allocated starting
>> at least from the value specified by NR_IRQS and going upwards, so
>> the check of (irq >= NR_IRQ) to decide about an error code returned by
>> platform_get_irq() is completely invalid, don't attempt to overrule
>> irq subsystem in the driver.
>>
>> The change fixes LPC32xx NAND MLC driver initialization on boot.
> 
> Do you need to backport this fix to stable releases? If that's the
> case, I'll add the Cc: stable tag when applying.

that will be great if you can add

Cc: stable@kernel.org # v4.7+

Please feel free to add also the tag

Fixes: 8cb17b5ed017 ("irqchip: Add LPC32xx interrupt controller driver")

--
With best wishes,
Vladimir
Boris BREZILLON Jan. 3, 2017, 10:47 a.m. UTC | #4
On Tue, 3 Jan 2017 12:16:26 +0200
Vladimir Zapolskiy <vz@mleia.com> wrote:

> Hi Boris,
> 
> On 01/03/2017 11:12 AM, Boris Brezillon wrote:
> > Hi Vladimir
> > 
> > On Mon,  5 Dec 2016 03:47:10 +0200
> > Vladimir Zapolskiy <vz@mleia.com> wrote:
> >   
> >> Semantics of NR_IRQS is different on machines with SPARSE_IRQ option
> >> disabled or enabled, in the latter case IRQs are allocated starting
> >> at least from the value specified by NR_IRQS and going upwards, so
> >> the check of (irq >= NR_IRQ) to decide about an error code returned by
> >> platform_get_irq() is completely invalid, don't attempt to overrule
> >> irq subsystem in the driver.
> >>
> >> The change fixes LPC32xx NAND MLC driver initialization on boot.  
> > 
> > Do you need to backport this fix to stable releases? If that's the
> > case, I'll add the Cc: stable tag when applying.  
> 
> that will be great if you can add
> 
> Cc: stable@kernel.org # v4.7+
> 
> Please feel free to add also the tag
> 
> Fixes: 8cb17b5ed017 ("irqchip: Add LPC32xx interrupt controller driver")

Applied to nand/next (this patch will appear in 4.11).

Thanks,

Boris

> 
> --
> With best wishes,
> Vladimir
>
Brian Norris Jan. 5, 2017, 5:58 p.m. UTC | #5
On Tue, Jan 03, 2017 at 11:47:46AM +0100, Boris Brezillon wrote:
> On Tue, 3 Jan 2017 12:16:26 +0200
> Vladimir Zapolskiy <vz@mleia.com> wrote:
> > On 01/03/2017 11:12 AM, Boris Brezillon wrote:
> > > Do you need to backport this fix to stable releases? If that's the
> > > case, I'll add the Cc: stable tag when applying.  
> > 
> > that will be great if you can add
> > 
> > Cc: stable@kernel.org # v4.7+
> > 
> > Please feel free to add also the tag
> > 
> > Fixes: 8cb17b5ed017 ("irqchip: Add LPC32xx interrupt controller driver")
> 
> Applied to nand/next (this patch will appear in 4.11).

For next time, checkpatch noticed that you got the stable address wrong:

ERROR:STABLE_ADDRESS: The 'stable' address should be 'stable@vger.kernel.org'
#17: Cc: stable@kernel.org # v4.7+

Brian
Vladimir Zapolskiy Jan. 5, 2017, 6:19 p.m. UTC | #6
On 01/05/2017 07:58 PM, Brian Norris wrote:
> On Tue, Jan 03, 2017 at 11:47:46AM +0100, Boris Brezillon wrote:
>> On Tue, 3 Jan 2017 12:16:26 +0200
>> Vladimir Zapolskiy <vz@mleia.com> wrote:
>>> On 01/03/2017 11:12 AM, Boris Brezillon wrote:
>>>> Do you need to backport this fix to stable releases? If that's the
>>>> case, I'll add the Cc: stable tag when applying.  
>>>
>>> that will be great if you can add
>>>
>>> Cc: stable@kernel.org # v4.7+
>>>
>>> Please feel free to add also the tag
>>>
>>> Fixes: 8cb17b5ed017 ("irqchip: Add LPC32xx interrupt controller driver")
>>
>> Applied to nand/next (this patch will appear in 4.11).
> 
> For next time, checkpatch noticed that you got the stable address wrong:
> 
> ERROR:STABLE_ADDRESS: The 'stable' address should be 'stable@vger.kernel.org'
> #17: Cc: stable@kernel.org # v4.7+
> 
> Brian
> 

sorry, I've git-logged to commit 52bce91165 and pasted the address from
its commit message.

--
With best wishes,
Vladimir
diff mbox

Patch

diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
index 8523881..bc6e49a 100644
--- a/drivers/mtd/nand/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/lpc32xx_mlc.c
@@ -776,7 +776,7 @@  static int lpc32xx_nand_probe(struct platform_device *pdev)
 	init_completion(&host->comp_controller);
 
 	host->irq = platform_get_irq(pdev, 0);
-	if ((host->irq < 0) || (host->irq >= NR_IRQS)) {
+	if (host->irq < 0) {
 		dev_err(&pdev->dev, "failed to get platform irq\n");
 		res = -EINVAL;
 		goto err_exit3;