mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "David Lechner (TI)" <dlechner@baylibre.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH 1/2] iio: adc: ti-ads112c14: fix negative settlingtime check
Date: Sat, 26 Sep 2026 01:23:04 +0100	[thread overview]
Message-ID: <20260926012304.6eb5aaab@jic23-hlaptop> (raw)
In-Reply-To: <20260925-iio-adc-ti-ads112c14-fix-settlingtime-sign-v1-1-1fd53e7242e8@baylibre.com>

On Fri, 25 Sep 2026 16:27:43 -0500
"David Lechner (TI)" <dlechner@baylibre.com> wrote:

> Fix checking for negative values when writing the settlingtime
> attribute. MICRO is an unsigned long, so on 32-bit architectures,
> integer * MICRO is evaluated as a 32-bit unsigned value. A negative
> integer part is then zero-extended to a positive s64 and passes the
> < 0 check. Large positive values can also wrap around.
> 
> Reject negative input before doing the multiplication and do the
> multiplication as 64-bit.
> 
> Fixes: 839cbb1e2331 ("iio: adc: ti-ads112c14: add settlingtime attribute")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/message/20260910-iio-adc-ti-ads112c14-filter-support-v3-9-e5a9b27ddb1a%40baylibre.com
> Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
> ---
>  drivers/iio/adc/ti-ads112c14.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
> index 3c877126b0be..483f159e2836 100644
> --- a/drivers/iio/adc/ti-ads112c14.c
> +++ b/drivers/iio/adc/ti-ads112c14.c
> @@ -729,10 +729,11 @@ static ssize_t ads112c14_write_settling_time(struct iio_dev *indio_dev,
>  	if (ret)
>  		return ret;
>  
> -	settling_time_us = integer * MICRO + fract;
> -	if (settling_time_us < 0)
> +	if (integer < 0 || fract < 0)
>  		return -EINVAL;
>  
> +	settling_time_us = (s64)integer * MICRO + fract;
Hi David,

Given you sanity checked that this can't be negative, is it worth changing
settling_time_us to a u64 to reflect that?

Jonathan

> +
>  	IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
>  	if (IIO_DEV_ACQUIRE_FAILED(claim))
>  		return -EBUSY;
> 


  reply	other threads:[~2026-09-26  0:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 21:27 [PATCH 0/2] iio: adc: ti-ads112c14: minor fixes David Lechner (TI)
2026-09-25 21:27 ` [PATCH 1/2] iio: adc: ti-ads112c14: fix negative settlingtime check David Lechner (TI)
2026-09-26  0:23   ` Jonathan Cameron [this message]
2026-09-25 21:27 ` [PATCH 2/2] iio: adc: ti-ads112c14: fix settlingtime creep on write back David Lechner (TI)

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=20260926012304.6eb5aaab@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=sashiko-bot@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

all inboxes | Powered by JetHome®