All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: cpcap: fix incorrect validation
@ 2017-11-12 16:01 Pan Bian
  2017-11-12 18:28 ` Sebastian Reichel
  0 siblings, 1 reply; 5+ messages in thread
From: Pan Bian @ 2017-11-12 16:01 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Tony Lindgren, Sebastian Reichel,
	Rob Herring
  Cc: linux-iio, linux-kernel, Pan Bian

Function platform_get_irq_byname() returns a negative error code on
failure, and a zero or positive number on success. However, in function
cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
return value of platform_get_irq_byname().

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/iio/adc/cpcap-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c
index 6e419d5..f153e026 100644
--- a/drivers/iio/adc/cpcap-adc.c
+++ b/drivers/iio/adc/cpcap-adc.c
@@ -1012,7 +1012,7 @@ static int cpcap_adc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, indio_dev);
 
 	ddata->irq = platform_get_irq_byname(pdev, "adcdone");
-	if (!ddata->irq)
+	if (ddata->irq < 0)
 		return -ENODEV;
 
 	error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL,
-- 
1.9.1

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

* Re: [PATCH] iio: adc: cpcap: fix incorrect validation
  2017-11-12 16:01 [PATCH] iio: adc: cpcap: fix incorrect validation Pan Bian
@ 2017-11-12 18:28 ` Sebastian Reichel
  2017-11-13 18:49     ` Tony Lindgren
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2017-11-12 18:28 UTC (permalink / raw)
  To: Pan Bian
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Tony Lindgren, Rob Herring, linux-iio,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]

Hi,

On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote:
> Function platform_get_irq_byname() returns a negative error code on
> failure, and a zero or positive number on success. However, in function
> cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
> Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
> return value of platform_get_irq_byname().
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/iio/adc/cpcap-adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c
> index 6e419d5..f153e026 100644
> --- a/drivers/iio/adc/cpcap-adc.c
> +++ b/drivers/iio/adc/cpcap-adc.c
> @@ -1012,7 +1012,7 @@ static int cpcap_adc_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, indio_dev);
>  
>  	ddata->irq = platform_get_irq_byname(pdev, "adcdone");
> -	if (!ddata->irq)
> +	if (ddata->irq < 0)
>  		return -ENODEV;
>  
>  	error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL,
> -- 
> 1.9.1
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] iio: adc: cpcap: fix incorrect validation
  2017-11-12 18:28 ` Sebastian Reichel
@ 2017-11-13 18:49     ` Tony Lindgren
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2017-11-13 18:49 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Pan Bian, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, linux-iio, linux-kernel

* Sebastian Reichel <sre@kernel.org> [171112 18:30]:
> Hi,
> 
> On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote:
> > Function platform_get_irq_byname() returns a negative error code on
> > failure, and a zero or positive number on success. However, in function
> > cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
> > Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
> > return value of platform_get_irq_byname().
> > 
> > Signed-off-by: Pan Bian <bianpan2016@163.com>
> > ---
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH] iio: adc: cpcap: fix incorrect validation
@ 2017-11-13 18:49     ` Tony Lindgren
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2017-11-13 18:49 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Pan Bian, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, linux-iio, linux-kernel

* Sebastian Reichel <sre@kernel.org> [171112 18:30]:
> Hi,
>=20
> On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote:
> > Function platform_get_irq_byname() returns a negative error code on
> > failure, and a zero or positive number on success. However, in function
> > cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
> > Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
> > return value of platform_get_irq_byname().
> >=20
> > Signed-off-by: Pan Bian <bianpan2016@163.com>
> > ---
>=20
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH] iio: adc: cpcap: fix incorrect validation
  2017-11-13 18:49     ` Tony Lindgren
  (?)
@ 2017-11-19 11:34     ` Jonathan Cameron
  -1 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2017-11-19 11:34 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Pan Bian, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, linux-iio, linux-kernel

On Mon, 13 Nov 2017 10:49:03 -0800
Tony Lindgren <tony@atomide.com> wrote:

> * Sebastian Reichel <sre@kernel.org> [171112 18:30]:
> > Hi,
> > 
> > On Mon, Nov 13, 2017 at 12:01:20AM +0800, Pan Bian wrote:  
> > > Function platform_get_irq_byname() returns a negative error code on
> > > failure, and a zero or positive number on success. However, in function
> > > cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
> > > Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
> > > return value of platform_get_irq_byname().
> > > 
> > > Signed-off-by: Pan Bian <bianpan2016@163.com>
> > > ---  
> > 
> > Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>  
> 
> Acked-by: Tony Lindgren <tony@atomide.com>

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

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

end of thread, other threads:[~2017-11-19 11:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-12 16:01 [PATCH] iio: adc: cpcap: fix incorrect validation Pan Bian
2017-11-12 18:28 ` Sebastian Reichel
2017-11-13 18:49   ` Tony Lindgren
2017-11-13 18:49     ` Tony Lindgren
2017-11-19 11:34     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.