Skip to contentSkip to conversation

iio: mxs-lradc: Fix misuse of iio->trig

PATCH In review Marek Vasut 2 participants 3 messages Jun 29, 2013 – Jul 3, 2013

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

PATCH 1/1 iio: mxs-lradc: Fix misuse of iio->trig

The struct iio_dev .trig field is to be used only by the IIO core, the driver shall not fill this field. This fixes ugly crash when the driver is compiled as a module and the module is rmmod'd.

Cc Fabio Estevam <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Shawn Guo <[email protected]>
---
 drivers/staging/iio/adc/mxs-lradc.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +7 -4
index 55a459b..28e029a 100644
@@ -664,12 +664,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
 {
 	int ret;
 	struct iio_trigger *trig;
+	struct mxs_lradc *lradc = iio_priv(iio);
 
 	trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
 	if (trig == NULL)
 		return -ENOMEM;
 
-	trig->dev.parent = iio->dev.parent;
+	trig->dev.parent = lradc->dev;
 	trig->private_data = iio;
 	trig->ops = &mxs_lradc_trigger_ops;
 
@@ -679,15 +680,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
 		return ret;
 	}
 
-	iio->trig = trig;
+	lradc->trig = trig;
 
 	return 0;
 }
 
 static void mxs_lradc_trigger_remove(struct iio_dev *iio)
 {
-	iio_trigger_unregister(iio->trig);
-	iio_trigger_free(iio->trig);
+	struct mxs_lradc *lradc = iio_priv(iio);
+
+	iio_trigger_unregister(lradc->trig);
+	iio_trigger_free(lradc->trig);
 }
 
 static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw
Quoted 8 lines · Marek Vasut

The struct iio_dev .trig field is to be used only by the IIO core, the driver shall not fill this field. This fixes ugly crash when the driver is compiled as a module and the module is rmmod'd.

Cc Fabio Estevam <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Shawn Guo <[email protected]>

I've applied this to the fixes-togreg branch of iio.git but had a bit of fuzz, could you just santiy check that nothing went wrong please.

https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/log/?h=fixes-togreg

Thanks

Jonathan

Quoted 45 lines
---
 drivers/staging/iio/adc/mxs-lradc.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +7 -4
index 55a459b..28e029a 100644
@@ -664,12 +664,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
 {
 	int ret;
 	struct iio_trigger *trig;
+	struct mxs_lradc *lradc = iio_priv(iio);
 
 	trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
 	if (trig == NULL)
 		return -ENOMEM;
 
-	trig->dev.parent = iio->dev.parent;
+	trig->dev.parent = lradc->dev;
 	trig->private_data = iio;
 	trig->ops = &mxs_lradc_trigger_ops;
 
@@ -679,15 +680,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
 		return ret;
 	}
 
-	iio->trig = trig;
+	lradc->trig = trig;
 
 	return 0;
 }
 
 static void mxs_lradc_trigger_remove(struct iio_dev *iio)
 {
-	iio_trigger_unregister(iio->trig);
-	iio_trigger_free(iio->trig);
+	struct mxs_lradc *lradc = iio_priv(iio);
+
+	iio_trigger_unregister(lradc->trig);
+	iio_trigger_free(lradc->trig);
 }
 
 static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
#2 lore raw

Hello Jonathan,

Quoted 10 lines · Marek Vasut
Quoted 8 lines

The struct iio_dev .trig field is to be used only by the IIO core, the driver shall not fill this field. This fixes ugly crash when the driver is compiled as a module and the module is rmmod'd.

Cc Fabio Estevam <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Shawn Guo <[email protected]>
Quoted 7 lines

I've applied this to the fixes-togreg branch of iio.git but had a bit of fuzz, could you just santiy check that nothing went wrong please.

https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/log/?h=fixes-tog
reg

Thanks

All OK, it must be my -next tree, sorry for the trouble.

Best regards,
Marek Vasut