mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Ethan Tidmore <ethantidmore06@gmail.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Jonathan Santos <Jonathan.Santos@analog.com>
Cc: Andy Shevchenko <andy@kernel.org>,
	linux-iio@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad7768-1: Fix ERR_PTR dereference in ad7768_fill_scale_tbl
Date: Fri, 13 Feb 2026 16:47:36 +0000	[thread overview]
Message-ID: <61edeb390553a8e7419a8cce6d92af53123b9960.camel@gmail.com> (raw)
In-Reply-To: <20260213031207.21291-1-ethantidmore06@gmail.com>

On Thu, 2026-02-12 at 21:12 -0600, Ethan Tidmore wrote:
> The function iio_get_current_scan_type() can return ERR_PTR, the return
> value scan_type is not checked for this and immediately dereferenced
> which can cause a kernel panic.
> 
> Add check for IS_ERR() and return early to avoid crash.
> 
> Fixes: ff085189cb17 ("iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  drivers/iio/adc/ad7768-1.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index fcd8aea7152e..f45a09e39367 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
> @@ -541,6 +541,11 @@ static void ad7768_fill_scale_tbl(struct iio_dev *dev)
>  	u64 tmp2;
>  
>  	scan_type = iio_get_current_scan_type(dev, &dev->channels[0]);
> +	if (IS_ERR(scan_type)) {
> +		dev_err(&st->spi->dev, "Failed to get scan type.\n");
> +		return;
> +	}
> +

With the above, it could make sense to change the function to propagate the error back...

- Nuno Sá

>  	if (scan_type->sign == 's')
>  		val2 = scan_type->realbits - 1;
>  	else

      parent reply	other threads:[~2026-02-13 16:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13  3:12 Ethan Tidmore
2026-02-13  9:22 ` Andy Shevchenko
2026-02-13 16:47 ` Nuno Sá [this message]

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=61edeb390553a8e7419a8cce6d92af53123b9960.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Jonathan.Santos@analog.com \
    --cc=andy@kernel.org \
    --cc=ethantidmore06@gmail.com \
    --cc=jic23@kernel.org \
    --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

all inboxes | Powered by JetHome®