linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging:iio:lpc32xx_adc: Fix IRQ check
@ 2013-10-16 20:45 Lars-Peter Clausen
  2013-10-16 20:45 ` [PATCH 2/2] staging:iio:spear_adc: " Lars-Peter Clausen
  2013-10-17 22:13 ` [PATCH 1/2] staging:iio:lpc32xx_adc: " Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-10-16 20:45 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Roland Stigge

The test in the lpc32xx_adc driver which checks whether the IRQ number returned
by platform_get_irq() has multiple problems. It accepts 0 even though this is an
invalid IRQ. It also rejects IRQ numbers that are larger or equal than NR_IRQS.
First of all drivers should never need to reference NR_IRQS and secondly with
CONFIG_SPARSE_IRQ NR_IRQS is not the upper limit, so the check might reject
valid IRQ numbers. This patch modifies the check to only test against less or
equal to 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Roland Stigge <stigge@antcom.de>
---
 drivers/staging/iio/adc/lpc32xx_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c
index ce7ff3e..ef0a21d 100644
--- a/drivers/staging/iio/adc/lpc32xx_adc.c
+++ b/drivers/staging/iio/adc/lpc32xx_adc.c
@@ -160,7 +160,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
 	}
 
 	irq = platform_get_irq(pdev, 0);
-	if ((irq < 0) || (irq >= NR_IRQS)) {
+	if (irq <= 0) {
 		dev_err(&pdev->dev, "failed getting interrupt resource\n");
 		return -EINVAL;
 	}
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] staging:iio:spear_adc: Fix IRQ check
  2013-10-16 20:45 [PATCH 1/2] staging:iio:lpc32xx_adc: Fix IRQ check Lars-Peter Clausen
@ 2013-10-16 20:45 ` Lars-Peter Clausen
  2013-10-17 22:14   ` Jonathan Cameron
  2013-10-17 22:13 ` [PATCH 1/2] staging:iio:lpc32xx_adc: " Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-10-16 20:45 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Stefan Roese

The test in the spear_adc driver which checks whether the IRQ number returned
by platform_get_irq() has multiple problems. It accepts 0 even though this is
an invalid IRQ. It also rejects IRQ numbers that are larger or equal than
NR_IRQS. First of all drivers should never need to reference NR_IRQS and
secondly with CONFIG_SPARSE_IRQ NR_IRQS is not the upper limit, so the check
might reject valid IRQ numbers. This patch modifies the check to only test
against less or equal to 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Stefan Roese <sr@denx.de>
---
 drivers/staging/iio/adc/spear_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
index e6555b6..970d9ed 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -333,7 +333,7 @@ static int spear_adc_probe(struct platform_device *pdev)
 	}
 
 	irq = platform_get_irq(pdev, 0);
-	if ((irq < 0) || (irq >= NR_IRQS)) {
+	if (irq <= 0) {
 		dev_err(dev, "failed getting interrupt resource\n");
 		ret = -EINVAL;
 		goto errout3;
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] staging:iio:lpc32xx_adc: Fix IRQ check
  2013-10-16 20:45 [PATCH 1/2] staging:iio:lpc32xx_adc: Fix IRQ check Lars-Peter Clausen
  2013-10-16 20:45 ` [PATCH 2/2] staging:iio:spear_adc: " Lars-Peter Clausen
@ 2013-10-17 22:13 ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2013-10-17 22:13 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Roland Stigge

On 10/16/13 21:45, Lars-Peter Clausen wrote:
> The test in the lpc32xx_adc driver which checks whether the IRQ number returned
> by platform_get_irq() has multiple problems. It accepts 0 even though this is an
> invalid IRQ. It also rejects IRQ numbers that are larger or equal than NR_IRQS.
> First of all drivers should never need to reference NR_IRQS and secondly with
> CONFIG_SPARSE_IRQ NR_IRQS is not the upper limit, so the check might reject
> valid IRQ numbers. This patch modifies the check to only test against less or
> equal to 0.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Cc: Roland Stigge <stigge@antcom.de>
Applied to the togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/staging/iio/adc/lpc32xx_adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c
> index ce7ff3e..ef0a21d 100644
> --- a/drivers/staging/iio/adc/lpc32xx_adc.c
> +++ b/drivers/staging/iio/adc/lpc32xx_adc.c
> @@ -160,7 +160,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
>  	}
>  
>  	irq = platform_get_irq(pdev, 0);
> -	if ((irq < 0) || (irq >= NR_IRQS)) {
> +	if (irq <= 0) {
>  		dev_err(&pdev->dev, "failed getting interrupt resource\n");
>  		return -EINVAL;
>  	}
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] staging:iio:spear_adc: Fix IRQ check
  2013-10-16 20:45 ` [PATCH 2/2] staging:iio:spear_adc: " Lars-Peter Clausen
@ 2013-10-17 22:14   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2013-10-17 22:14 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio, Stefan Roese

On 10/16/13 21:45, Lars-Peter Clausen wrote:
> The test in the spear_adc driver which checks whether the IRQ number returned
> by platform_get_irq() has multiple problems. It accepts 0 even though this is
> an invalid IRQ. It also rejects IRQ numbers that are larger or equal than
> NR_IRQS. First of all drivers should never need to reference NR_IRQS and
> secondly with CONFIG_SPARSE_IRQ NR_IRQS is not the upper limit, so the check
> might reject valid IRQ numbers. This patch modifies the check to only test
> against less or equal to 0.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Cc: Stefan Roese <sr@denx.de>
Applied to the togreg branch of iio.git

Thanks for dealing with this so quickly.

Jonathan
> ---
>  drivers/staging/iio/adc/spear_adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
> index e6555b6..970d9ed 100644
> --- a/drivers/staging/iio/adc/spear_adc.c
> +++ b/drivers/staging/iio/adc/spear_adc.c
> @@ -333,7 +333,7 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	}
>  
>  	irq = platform_get_irq(pdev, 0);
> -	if ((irq < 0) || (irq >= NR_IRQS)) {
> +	if (irq <= 0) {
>  		dev_err(dev, "failed getting interrupt resource\n");
>  		ret = -EINVAL;
>  		goto errout3;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-17 21:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16 20:45 [PATCH 1/2] staging:iio:lpc32xx_adc: Fix IRQ check Lars-Peter Clausen
2013-10-16 20:45 ` [PATCH 2/2] staging:iio:spear_adc: " Lars-Peter Clausen
2013-10-17 22:14   ` Jonathan Cameron
2013-10-17 22:13 ` [PATCH 1/2] staging:iio:lpc32xx_adc: " Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).