From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>,
Michael Auchter <michael.auchter@ni.com>,
linux@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
Michael Hennerich <Michael.Hennerich@analog.com>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
sashiko-bot@kernel.org
Subject: Re: [PATCH v8 2/8] iio: dac: ad5686: missing NULL check on match data
Date: Sun, 19 Jul 2026 01:09:16 +0100 [thread overview]
Message-ID: <20260719010916.54de1870@jic23-huawei> (raw)
In-Reply-To: <20260719005533.41520a27@jic23-huawei>
On Sun, 19 Jul 2026 00:55:44 +0100
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com> wrote:
> On Fri, 17 Jul 2026 13:28:52 +0300
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
>
> > On Fri, Jul 17, 2026 at 10:31:26AM +0100, Rodrigo Alencar wrote:
> > > On 17/07/26 11:15, Andy Shevchenko wrote:
> > > > On Fri, Jul 17, 2026 at 07:51:35AM +0100, Rodrigo Alencar wrote:
> > > > > On 16/07/26 21:42, Andy Shevchenko wrote:
> > > > > > On Thu, Jul 16, 2026 at 01:14:18PM +0100, Rodrigo Alencar via B4 Relay wrote:
> >
> > ...
> >
> > > > > > > struct iio_dev *indio_dev;
> > > > > > > int ret, i;
> > > > > >
> > > > > > Move an assignment here as well.
> > > > > >
> > > > > > chip_info = ...
> > > > >
> > > > > assignment? this is an input param validation
> > > >
> > > > Can we make sure we always get a correct one to begin with?
> > > > With that an assignment and check can be coupled together.
> > > > Also consider use -ENODATA as it's most likely comes from
> > > > driver_data.
> > >
> > > I suppose you are suggesting to move the check to the bus code with:
> > >
> > > info = i2c_get_match_data(i2c);
> > > if (!info)
> > > return -ENODATA;
> > >
> > > rather than here in the core/common code.
> >
> > Yes! This avoids layering violation and makes the API contract cleaner.
>
> I applied the following rather than going for a v9 for just this:
> Shout if I messed it up.
>
> diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c
> index 8abfaf8f0c46..591596a68004 100644
> --- a/drivers/iio/dac/ad5686-spi.c
> +++ b/drivers/iio/dac/ad5686-spi.c
> @@ -98,8 +98,13 @@ static const struct ad5686_bus_ops ad5686_spi_ops = {
>
> static int ad5686_spi_probe(struct spi_device *spi)
> {
> - return ad5686_probe(&spi->dev, spi_get_device_match_data(spi),
> - spi->modalias, &ad5686_spi_ops);
> + const struct ad5686_chip_info *chip_info;
Renamed these to info to match the later patch that has this code anyway.
> +
> + chip_info = spi_get_device_match_data(spi);
> + if (!chip_info)
> + return -ENODEV;
> +
> + return ad5686_probe(&spi->dev, chip_info, spi->modalias, &ad5686_spi_ops);
> }
>
> static const struct spi_device_id ad5686_spi_id[] = {
> diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
> index d49946adbde3..a6c85d0c33c9 100644
> --- a/drivers/iio/dac/ad5696-i2c.c
> +++ b/drivers/iio/dac/ad5696-i2c.c
> @@ -68,8 +68,13 @@ static const struct ad5686_bus_ops ad5686_i2c_ops = {
>
> static int ad5686_i2c_probe(struct i2c_client *i2c)
> {
> - return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c),
> - i2c->name, &ad5686_i2c_ops);
> + const struct ad5686_chip_info *chip_info;
> +
> + chip_info = i2c_get_match_data(i2c);
> + if (!chip_info)
> + return -ENODEV;
> +
> + return ad5686_probe(&i2c->dev, chip_info, i2c->name, &ad5686_i2c_ops);
> }
>
>
> >
> > > > > > > + if (!chip_info)
> > > > > > > + return -ENODEV;
> >
>
>
next prev parent reply other threads:[~2026-07-19 0:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 12:14 [PATCH v8 0/8] New features for the AD5686 IIO driver Rodrigo Alencar via B4 Relay
2026-07-16 12:14 ` [PATCH v8 1/8] iio: dac: ad5696: properly check i2c_transfer() return value Rodrigo Alencar via B4 Relay
2026-07-16 12:28 ` sashiko-bot
2026-07-18 23:40 ` Jonathan Cameron
2026-07-16 12:14 ` [PATCH v8 2/8] iio: dac: ad5686: missing NULL check on match data Rodrigo Alencar via B4 Relay
2026-07-16 12:27 ` sashiko-bot
2026-07-16 13:05 ` Joshua Crofts
2026-07-16 18:42 ` Andy Shevchenko
2026-07-16 19:08 ` Joshua Crofts
2026-07-17 6:51 ` Rodrigo Alencar
2026-07-17 8:15 ` Andy Shevchenko
2026-07-17 9:31 ` Rodrigo Alencar
2026-07-17 10:28 ` Andy Shevchenko
2026-07-18 23:55 ` Jonathan Cameron
2026-07-19 0:09 ` Jonathan Cameron [this message]
2026-07-19 8:50 ` Andy Shevchenko
2026-07-16 12:14 ` [PATCH v8 3/8] iio: dac: ad5686: refactor command/data macros Rodrigo Alencar via B4 Relay
2026-07-18 23:46 ` Jonathan Cameron
2026-07-18 23:59 ` Jonathan Cameron
2026-07-16 12:14 ` [PATCH v8 4/8] iio: dac: ad5686: introduce sync operation Rodrigo Alencar via B4 Relay
2026-07-16 12:14 ` [PATCH v8 5/8] iio: dac: ad5686: implement new sync() op for the spi bus Rodrigo Alencar via B4 Relay
2026-07-16 12:32 ` sashiko-bot
2026-07-16 12:14 ` [PATCH v8 6/8] iio: dac: ad5686: read_raw/write_raw: use guard(mutex)() Rodrigo Alencar via B4 Relay
2026-07-16 12:14 ` [PATCH v8 7/8] iio: dac: ad5686: add triggered buffer support Rodrigo Alencar via B4 Relay
2026-07-16 12:14 ` [PATCH v8 8/8] iio: dac: ad5686: add gain control support Rodrigo Alencar via B4 Relay
2026-07-19 0:15 ` [PATCH v8 0/8] New features for the AD5686 IIO driver 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=20260719010916.54de1870@jic23-huawei \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=455.rodrigo.alencar@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=michael.auchter@ni.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--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