Skip to contentSkip to conversation

FAILED: patch "[PATCH] iio: adc: ad7192: reject devices without match data" failed to apply to 6.12-stable tree

PATCH New Sasha Levin 1 participant 3 messages Nov 7 – Nov 10

Subsystems (4)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 6.12-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.12.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.12.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.

Fixes c3708c829a06 ("iio: adc: ad7192: Convert from of specific to fwnode property handling")
---
 drivers/iio/adc/ad7192.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7192.c +3 -0
index d8f5886fcf694..8bd8105463111 100644
@@ -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
author maintainer
#1 lore raw

PATCH 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
index 6fe32f866765b..02328b9115756 100644
@@ -1394,9 +1394,6 @@ 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 -ENODEV;
-
 	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
author maintainer
#2 lore raw

PATCH 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.

Fixes c3708c829a06 ("iio: adc: ad7192: Convert from of specific to fwnode property handling")
---
 drivers/iio/adc/ad7192.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7192.c +3 -0
index 02328b9115756..ef8268ad353e0 100644
@@ -1394,6 +1394,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