FAILED: patch "[PATCH] iio: adc: ad7192: reject devices without match data" failed to apply to 6.6-stable tree
Sasha Levin
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 7f7a119a370ecf6c8d4ab9e9ee0a8cdd77afedd3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 7f7a119a370ecf6c8d4ab9e9ee0a8cdd77afedd3 Mon Sep 17 00:00:00 2001
From: Jiale Yao <[email protected]>
Date: Fri, 25 Sep 2026 20:57:39 +0800
Subject: [PATCH] iio: adc: ad7192: reject devices without match data
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.
ad7192_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 using the chip information.
--- drivers/iio/adc/ad7192.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7192.c +3 -0
@@ -1406,6 +1406,9 @@ static int ad7192_probe(struct spi_device *spi) st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret /MILLI ; st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODATA ; + indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = st->chip_info->info;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/2 iio: adc: ad7192: Revert "properly check spi_get_device_match_data()"
From: Andy Shevchenko <[email protected]>
[ Upstream commit 0309e66abea141f3ec339b064b8f8b8003d2a634 ]
This reverts commit b7f99fa1b64af2f696b13cec581cb4cd7d3982b8.
The added code is currently a dead code. Moreover, the driver is not designed to have any defaults effectively making driver data a mandatory information to work with. Taking all together, revert unneeded change.
Discussion at #1 concluded in agreeing a new policy on this for IIO.
Stable-dep-of: 7f7a119a370e ("iio: adc: ad7192: reject devices without match data")
--- drivers/iio/adc/ad7192.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/adc/ad7192.c +0 -3
@@ -1039,9 +1039,6 @@ static int ad7192_probe(struct spi_device *spi) st->int_vref_mv = ret /1000 ; st->chip_info =spi_get_device_match_data (spi); -if (!st->chip_info) -return -ENODEV ; - indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 iio: adc: ad7192: reject devices without match data
From: Jiale Yao <[email protected]>
[ Upstream commit 7f7a119a370ecf6c8d4ab9e9ee0a8cdd77afedd3 ]
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.
ad7192_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 using the chip information.
--- drivers/iio/adc/ad7192.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7192.c +3 -0
@@ -1039,6 +1039,9 @@ static int ad7192_probe(struct spi_device *spi) st->int_vref_mv = ret /1000 ; st->chip_info =spi_get_device_match_data (spi); +if (!st->chip_info) +return -ENODATA ; + indio_dev->name = st->chip_info->name; indio_dev->modes =INDIO_DIRECT_MODE ;
Signature · 1 line
2.53.0