Skip to contentSkip to conversation

iio: imu: Use iio_trigger_get for indio_dev->trig assignment

PATCH Applied Darshana Padmadas 2 participants 2 messages Mar 28, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: Use iio_trigger_get for indio_dev->trig assignment

This patch uses iio_trigger_get to increment the reference count of trigger device, to avoid incorrect assignment.

This patch refers to a similar situation encountered through the following discussion:
http://www.spinics.net/lists/linux-iio/msg13669.html

---
 drivers/iio/imu/adis_trigger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/adis_trigger.c +1 -1
index e0017c2..f53e9a8 100644
@@ -60,7 +60,7 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
 	iio_trigger_set_drvdata(adis->trig, adis);
 	ret = iio_trigger_register(adis->trig);
 
-	indio_dev->trig = adis->trig;
+	indio_dev->trig = iio_trigger_get(adis->trig);
 	if (ret)
 		goto error_free_irq;
 
Signature · 1 line
1.9.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Darshana Padmadas

This patch uses iio_trigger_get to increment the reference count of trigger device, to avoid incorrect assignment.

This patch refers to a similar situation encountered through the following discussion:
http://www.spinics.net/lists/linux-iio/msg13669.html

Applied to the fixes-togreg branch of iio.git with it marked for stable as well.

Added a note that this can cause a null pointer dereference to make it clear why this should be in stable.

Thanks,

Jonathan

Quoted 18 lines
---
 drivers/iio/imu/adis_trigger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/adis_trigger.c +1 -1
index e0017c2..f53e9a8 100644
@@ -60,7 +60,7 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
 	iio_trigger_set_drvdata(adis->trig, adis);
 	ret = iio_trigger_register(adis->trig);
 
-	indio_dev->trig = adis->trig;
+	indio_dev->trig = iio_trigger_get(adis->trig);
 	if (ret)
 		goto error_free_irq;