From: Jonathan Cameron <jic23@kernel.org>
To: Arnav Kapoor <kapoorarnav43@gmail.com>
Cc: "Marius Cristea" <marius.cristea@microchip.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: adc: mcp3564: reject devices without match data
Date: Sat, 24 Oct 2026 02:58:40 +0100 [thread overview]
Message-ID: <20261024025840.65257ab7@jic23-hlaptop> (raw)
In-Reply-To: <20261023185837.195943-1-kapoorarnav43@gmail.com>
On Sat, 24 Oct 2026 00:28:34 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:
> When the chip can't be identified from its ID registers, the driver
> falls back to spi_get_device_match_data() and dereferences the result
> unconditionally. That returns NULL for a device bound through
> driver_override whose name isn't in the id table, causing an oops.
>
> Return -ENODATA in that case.
>
> Fixes: 33ec3e5fc1ea ("iio: adc: adding support for MCP3564 ADC")
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Applied
> ---
> Changes in v2:
> - Shorten the commit message (Andy)
> - Add Fixes tag
> - Collect Andy's Reviewed-by
> - Rebase on fixes-togreg
>
> v1: https://lore.kernel.org/all/20261021225431.627718-1-kapoorarnav43@gmail.com/
>
> Compile-tested only (W=1); I don't have MCP3564 hardware.
>
> drivers/iio/adc/mcp3564.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
> index 259ac4ebdedf..91796a47e412 100644
> --- a/drivers/iio/adc/mcp3564.c
> +++ b/drivers/iio/adc/mcp3564.c
> @@ -1204,6 +1204,9 @@ static int mcp3564_config(struct iio_dev *indio_dev, bool *use_internal_vref_att
> * try using fallback compatible in device tree to deal with some newer part number.
> */
> adc->chip_info = spi_get_device_match_data(adc->spi);
> + if (!adc->chip_info)
> + return -ENODATA;
> +
> adc->have_vref = adc->chip_info->have_vref;
> } else {
> adc->chip_info = &mcp3564_chip_infos_tbl[ids];
>
> base-commit: 2ef6f5c4ee56e90c237c5f7687f09e635f7d30a9
prev parent reply other threads:[~2026-10-24 1:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 18:58 Arnav Kapoor
2026-10-24 1:58 ` Jonathan Cameron [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=20261024025840.65257ab7@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=kapoorarnav43@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marius.cristea@microchip.com \
--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®