mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kurt Borja" <kuurtb@gmail.com>
To: "Jiale Yao" <yaojiale02@163.com>, "Kurt Borja" <kuurtb@gmail.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: <stable@vger.kernel.org>
Subject: Re: [PATCH 7/9] iio: adc: ti-ads1018: reject devices without match data
Date: Fri, 25 Sep 2026 16:24:39 -0300	[thread overview]
Message-ID: <DLON63JAAXEO.18FNAXS16CHHB@gmail.com> (raw)
In-Reply-To: <20260925125754.2162337-8-yaojiale02@163.com>

On Fri Sep 25, 2026 at 9:57 AM -03, Jiale Yao wrote:
> SPI driver_override allows a device to bind to this driver without
> matching either the OF or SPI device ID table. In that case,
> spi_get_device_match_data() returns NULL.
>
> ads1018_spi_probe() immediately dereferences the returned chip
> information to initialize the IIO device, causing a NULL pointer
> dereference.
>
> Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match
> data") fixed the same driver_override issue in another SPI driver.
> Reject devices without match data before allocating the IIO device.
>
> Fixes: bf0bba486b5b ("iio: adc: Add ti-ads1018 driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiale Yao <yaojiale02@163.com>

Reviewed-by: Kurt Borja <kuurtb@gmail.com>

> ---
>  drivers/iio/adc/ti-ads1018.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ti-ads1018.c b/drivers/iio/adc/ti-ads1018.c
> index d9ec4a8d7ce5..8f2d03eee77b 100644
> --- a/drivers/iio/adc/ti-ads1018.c
> +++ b/drivers/iio/adc/ti-ads1018.c
> @@ -624,12 +624,16 @@ static int ads1018_trigger_setup(struct iio_dev *indio_dev)
>  
>  static int ads1018_spi_probe(struct spi_device *spi)
>  {
> -	const struct ads1018_chip_info *info = spi_get_device_match_data(spi);
> +	const struct ads1018_chip_info *info;
>  	struct device *dev = &spi->dev;
>  	struct iio_dev *indio_dev;
>  	struct ads1018 *ads1018;
>  	int ret;
>  
> +	info = spi_get_device_match_data(spi);
> +	if (!info)
> +		return -ENODATA;
> +
>  	indio_dev = devm_iio_device_alloc(dev, sizeof(*ads1018));
>  	if (!indio_dev)
>  		return -ENOMEM;

-- 
Thanks,
 ~ Kurt

  reply	other threads:[~2026-09-25 19:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 12:57 [PATCH 0/9] iio: adc: reject SPI " Jiale Yao
2026-09-25 12:57 ` [PATCH 1/9] iio: adc: ad7192: reject " Jiale Yao
2026-09-25 12:57 ` [PATCH 2/9] iio: adc: ad7606: " Jiale Yao
2026-09-25 12:57 ` [PATCH 3/9] iio: adc: ad7768-1: " Jiale Yao
2026-09-25 12:57 ` [PATCH 4/9] iio: adc: max11205: " Jiale Yao
2026-09-25 12:57 ` [PATCH 5/9] iio: adc: mcp3911: " Jiale Yao
2026-09-25 12:57 ` [PATCH 6/9] iio: adc: ti-adc128s052: validate SPI " Jiale Yao
2026-09-26  1:15   ` Jonathan Cameron
2026-09-26  1:18     ` Jonathan Cameron
2026-09-25 12:57 ` [PATCH 7/9] iio: adc: ti-ads1018: reject devices without " Jiale Yao
2026-09-25 19:24   ` Kurt Borja [this message]
2026-09-25 12:57 ` [PATCH 8/9] iio: adc: ti-ads131m02: " Jiale Yao
2026-09-25 12:57 ` [PATCH 9/9] iio: adc: ti-ads7950: validate SPI " Jiale Yao

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=DLON63JAAXEO.18FNAXS16CHHB@gmail.com \
    --to=kuurtb@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=stable@vger.kernel.org \
    --cc=yaojiale02@163.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

all inboxes | Powered by JetHome®