From: Jiale Yao <yaojiale02@163.com>
To: "Herve Codina" <herve.codina@bootlin.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: Jiale Yao <yaojiale02@163.com>
Subject: [PATCH 6/7] iio: potentiometer: x9250: reject devices without match data
Date: Fri, 25 Sep 2026 21:17:35 +0800 [thread overview]
Message-ID: <20260925131738.2200612-7-yaojiale02@163.com> (raw)
In-Reply-To: <20260925131738.2200612-1-yaojiale02@163.com>
A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but x9250_probe() later dereferences the result while naming the IIO
device.
Reject devices without match data before enabling the regulators.
Fixes: 66bfc528a6fd ("iio: potentiometer: Add support for the Renesas X9250 potentiometers")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/iio/potentiometer/x9250.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiometer/x9250.c
index 974e4447fc2c..675b78677baa 100644
--- a/drivers/iio/potentiometer/x9250.c
+++ b/drivers/iio/potentiometer/x9250.c
@@ -155,10 +155,15 @@ static const char *const x9250_regulator_names[] = {
static int x9250_probe(struct spi_device *spi)
{
+ const struct x9250_cfg *cfg;
struct iio_dev *indio_dev;
struct x9250 *x9250;
int ret;
+ cfg = spi_get_device_match_data(spi);
+ if (!cfg)
+ return -ENODATA;
+
ret = devm_regulator_bulk_get_enable(&spi->dev, ARRAY_SIZE(x9250_regulator_names),
x9250_regulator_names);
if (ret)
@@ -176,7 +181,7 @@ static int x9250_probe(struct spi_device *spi)
x9250 = iio_priv(indio_dev);
x9250->spi = spi;
- x9250->cfg = spi_get_device_match_data(spi);
+ x9250->cfg = cfg;
x9250->wp_gpio = devm_gpiod_get_optional(&spi->dev, "wp", GPIOD_OUT_LOW);
if (IS_ERR(x9250->wp_gpio))
return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio),
--
2.34.1
next prev parent reply other threads:[~2026-09-25 13:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 13:17 [PATCH 0/7] iio: validate SPI match data before use Jiale Yao
2026-09-25 13:17 ` [PATCH 1/7] iio: amplifiers: ad8366: reject devices without match data Jiale Yao
2026-09-25 13:17 ` [PATCH 2/7] iio: dac: ad5755: validate SPI " Jiale Yao
2026-09-25 13:17 ` [PATCH 3/7] iio: dac: mcp4821: reject devices without " Jiale Yao
2026-09-25 13:17 ` [PATCH 4/7] iio: frequency: adf4377: " Jiale Yao
2026-09-25 13:17 ` [PATCH 5/7] iio: imu: adis16400: validate SPI " Jiale Yao
2026-09-25 13:17 ` Jiale Yao [this message]
2026-09-25 13:17 ` [PATCH 7/7] iio: pressure: bmp280: " Jiale Yao
2026-09-26 1:11 ` [PATCH 0/7] iio: validate SPI match data before use Jonathan Cameron
2026-09-26 6:13 ` Uwe Kleine-König (The Capable Hub)
2026-09-27 17:20 ` Jonathan Cameron
2026-09-28 8:14 ` Andy Shevchenko
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=20260925131738.2200612-7-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=herve.codina@bootlin.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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®