From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: jic23@kernel.org, lars@metafoo.de, matthias.bgg@gmail.com,
nathan@kernel.org, ndesaulniers@google.com,
linus.walleij@linaro.org, ardeleanalex@gmail.com,
Tom Rix <trix@redhat.com>
Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Tom Rix <trix@redhat.com>
Subject: Re: [PATCH] iio: adc: mt6360: strengthen return check of mt6360_adc_read_channel
Date: Sun, 27 Feb 2022 18:01:47 +0100 [thread overview]
Message-ID: <5477fb05-d72f-ccc0-1c07-8f2f40d9dde0@wanadoo.fr> (raw)
In-Reply-To: <20220227164357.84742-1-trix@redhat.com>
Le 27/02/2022 à 17:43, trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org a
écrit :
> From: Tom Rix <trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> Clang static analysis reports this issue
> mt6360-adc.c:277:20: warning: Assigned value is
> garbage or undefined
> data.values[i++] = val;
> ^ ~~~
>
> val is set by a successful call to m6360_adc_read_channel().
> A negative return is checked but within m6360_adc_read_channel,
> a non zero check is done.
> Strengthen the check to non zero.
Hi, my understanding of m6360_adc_read_channel() is that on success, it
returns IIO_VAL_INT (i.e. 1).
So, I think that with your patch, we will now always fail because 'ret'
is never 0 at this point.
CJ
>
> Signed-off-by: Tom Rix <trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/iio/adc/mt6360-adc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
> index 07c0e67683910..9fb6dc305a392 100644
> --- a/drivers/iio/adc/mt6360-adc.c
> +++ b/drivers/iio/adc/mt6360-adc.c
> @@ -269,7 +269,7 @@ static irqreturn_t mt6360_adc_trigger_handler(int irq, void *p)
> memset(&data, 0, sizeof(data));
> for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) {
> ret = mt6360_adc_read_channel(mad, bit, &val);
> - if (ret < 0) {
> + if (ret) {
> dev_warn(&indio_dev->dev, "Failed to get channel %d conversion val\n", bit);
> goto out;
> }
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2022-02-27 17:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 16:43 [PATCH] iio: adc: mt6360: strengthen return check of mt6360_adc_read_channel trix
2022-02-27 17:01 ` Christophe JAILLET [this message]
2022-02-27 17:57 ` 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=5477fb05-d72f-ccc0-1c07-8f2f40d9dde0@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=ardeleanalex@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=matthias.bgg@gmail.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=trix@redhat.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