From: Darshana Padmadas Date: Sat, 28 Mar 2015 06:37:14 +0000 (+0530) Subject: iio: imu: Use iio_trigger_get for indio_dev->trig assignment X-Git-Tag: v4.9.8~4546^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ce7ca89d6e8eae9e201cd0e972ba323f33e2fb4;p=platform%2Fkernel%2Flinux-rpi3.git 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. Can result in a null pointer dereference during removal if the trigger has been changed before removal. This patch refers to a similar situation encountered through the following discussion: http://www.spinics.net/lists/linux-iio/msg13669.html Signed-off-by: Darshana Padmadas Cc: Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c index e0017c2..f53e9a8 100644 --- a/drivers/iio/imu/adis_trigger.c +++ b/drivers/iio/imu/adis_trigger.c @@ -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;