Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	 linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	 kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] iio: adc: ad4851: Fix signedness bug in ad4851_calibrate()
Date: Fri, 28 Feb 2025 13:24:20 +0000	[thread overview]
Message-ID: <5fa78e957fc85fa134cea5fa68b21b56c6173a44.camel@gmail.com> (raw)
In-Reply-To: <f5e260e9-d7a8-4dae-b7ea-f1bbb1760e60@stanley.mountain>

On Fri, 2025-02-28 at 12:36 +0300, Dan Carpenter wrote:
> The "c" variable is used to store error codes from ad4851_find_opt()
> so it has to be signed for the error handling to work.  Change it
> to type int.
> 
> Fixes: 6250803fe2ec ("iio: adc: ad4851: add ad485x driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

> Btw, in ad4851_write_raw() there are some checks for negative but
> the multiplication could still wrap and turn negative so we might want to
> add an upper bounds as well:
> 
>     drivers/iio/adc/ad4851.c:826 ad4851_write_raw()
>     warn: potential integer overflow from user 'val * st->osr'
> 
>  drivers/iio/adc/ad4851.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c
> index 1ad37084355e..98ebc853db79 100644
> --- a/drivers/iio/adc/ad4851.c
> +++ b/drivers/iio/adc/ad4851.c
> @@ -492,11 +492,11 @@ static int ad4851_find_opt(const unsigned long *field,
> unsigned int start,
>  static int ad4851_calibrate(struct iio_dev *indio_dev)
>  {
>  	struct ad4851_state *st = iio_priv(indio_dev);
> -	unsigned int opt_delay, num_lanes, delay, i, s, c;
> +	unsigned int opt_delay, num_lanes, delay, i, s;
>  	enum iio_backend_interface_type interface_type;
>  	DECLARE_BITMAP(pn_status, AD4851_MAX_LANES * AD4851_MAX_IODELAY);
>  	bool status;
> -	int ret;
> +	int c, ret;
>  
>  	ret = iio_backend_interface_type_get(st->back, &interface_type);
>  	if (ret)


  reply	other threads:[~2025-02-28 13:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  9:36 [PATCH next] iio: adc: ad4851: Fix signedness bug in ad4851_calibrate() Dan Carpenter
2025-02-28 13:24 ` Nuno Sá [this message]
2025-03-04 13:13   ` 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=5fa78e957fc85fa134cea5fa68b21b56c6173a44.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=antoniu.miclaus@analog.com \
    --cc=dan.carpenter@linaro.org \
    --cc=jic23@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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