The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Pan Bian <bianpan2016@163.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Tony Lindgren <tony@atomide.com>, Rob Herring <robh@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: cpcap: fix incorrect validation
Date: Sun, 12 Nov 2017 19:28:49 +0100	[thread overview]
Message-ID: <20171112182848.li5chdcsrhjv3du6@earth> (raw)
In-Reply-To: <1510502480-27117-1-git-send-email-bianpan2016@163.com>

[-- 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 --]

  reply	other threads:[~2017-11-12 18:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-12 16:01 [PATCH] iio: adc: cpcap: fix incorrect validation Pan Bian
2017-11-12 18:28 ` Sebastian Reichel [this message]
2017-11-13 18:49   ` Tony Lindgren
2017-11-19 11:34     ` Jonathan Cameron

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=20171112182848.li5chdcsrhjv3du6@earth \
    --to=sre@kernel.org \
    --cc=bianpan2016@163.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=robh@kernel.org \
    --cc=tony@atomide.com \
    /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