From: sashiko-bot@kernel.org
To: "Nuno Sá" <nuno.sa@analog.com>, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data
Date: Wed, 25 Nov 2026 10:33:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-233129@kernel.org> (raw)
In-Reply-To: <20261125-iio-adi-legacy-platdata-v1-6-54e4c8830b57@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] iio: adc: ad7793: unused OF match data and NULL deref in
ad7793_probe()
--
commit dd1daa501ec1006036cacb4fca5f16bb30f78354
Author: Nuno Sá <nuno.sa@analog.com>
iio: adc: ad7793: add firmware support and drop platform data
This commit replaces ad7793_platform_data with firmware property parsing,
enables the AVDD/DVDD supplies, and adds an OF match table.
> diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> index b0f44c144f20e..f3e3ca724ec2c 100644
> --- a/drivers/iio/adc/ad7793.c
> +++ b/drivers/iio/adc/ad7793.c
[ ... ]
> @@ -798,15 +1025,14 @@ static int ad7793_probe(struct spi_device *spi)
>
> ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
>
> - if (pdata->refsel != AD7793_REFSEL_INTERNAL) {
> - ret = devm_regulator_get_enable_read_voltage(dev, "refin");
> - if (ret < 0)
> - return ret;
> + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies),
> + supplies);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to enable supplies\n");
>
> - vref_mv = ret / 1000;
> - } else {
> - vref_mv = 1170; /* Built-in ref */
> - }
> + ret = ad7793_parse_fw(dev, &cfg, &vref_mv);
> + if (ret)
> + return ret;
>
> st->chip_info =
> &ad7793_chip_info_tbl[spi_get_device_id(spi)->driver_data];
[ ... ]
> @@ -842,9 +1068,24 @@ static const struct spi_device_id ad7793_id[] = {
> };
> MODULE_DEVICE_TABLE(spi, ad7793_id);
>
> +static const struct of_device_id ad7793_of_match[] = {
> + { .compatible = "adi,ad7785", .data = &ad7793_chip_info_tbl[ID_AD7785] },
> + { .compatible = "adi,ad7792", .data = &ad7793_chip_info_tbl[ID_AD7792] },
> + { .compatible = "adi,ad7793", .data = &ad7793_chip_info_tbl[ID_AD7793] },
> + { .compatible = "adi,ad7794", .data = &ad7793_chip_info_tbl[ID_AD7794] },
> + { .compatible = "adi,ad7795", .data = &ad7793_chip_info_tbl[ID_AD7795] },
> + { .compatible = "adi,ad7796", .data = &ad7793_chip_info_tbl[ID_AD7796] },
> + { .compatible = "adi,ad7797", .data = &ad7793_chip_info_tbl[ID_AD7797] },
> + { .compatible = "adi,ad7798", .data = &ad7793_chip_info_tbl[ID_AD7798] },
> + { .compatible = "adi,ad7799", .data = &ad7793_chip_info_tbl[ID_AD7799] },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, ad7793_of_match);
[Severity: High]
Can ad7793_probe() dereference NULL when a device matches via
ad7793_of_match?
ad7793_of_match stores struct ad7793_chip_info pointers in .data, while
ad7793_id stores enum indices in .driver_data, and ad7793_probe() still
looks up st->chip_info and indio_dev->name by unconditionally
dereferencing spi_get_device_id(spi). If a device matches through
ad7793_of_match without a matching spi->modalias in ad7793_id (such as via
ACPI PRP0001 or a fallback compatible string), spi_get_device_id(spi)
returns NULL and crashes in ad7793_probe().
Should ad7793_id also point to ad7793_chip_info_tbl entries (with the chip
name stored in struct ad7793_chip_info) so ad7793_probe() can use
spi_get_device_match_data(spi)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-iio-adi-legacy-platdata-v1-0-54e4c8830b57@analog.com?part=6
next prev parent reply other threads:[~2026-11-25 10:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
2026-11-25 10:19 ` [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic Nuno Sá
2026-11-25 10:25 ` sashiko-bot
2026-11-25 10:19 ` [PATCH 2/6] iio: adc: ad7887: drop platform data support Nuno Sá
2026-11-25 10:19 ` [PATCH 3/6] iio: adc: ad7266: " Nuno Sá
2026-11-25 10:19 ` [PATCH 4/6] iio: adc: ad7791: " Nuno Sá
2026-11-25 10:40 ` Andy Shevchenko
2026-11-25 10:19 ` [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs Nuno Sá
2026-11-25 10:28 ` sashiko-bot
2026-11-25 10:19 ` [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data Nuno Sá
2026-11-25 10:33 ` sashiko-bot [this message]
2026-11-25 10:43 ` Andy Shevchenko
2026-11-25 10:36 ` [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Arnd Bergmann
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=sashiko-outbox-233129@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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