Skip to content

Commit 9354c22

Browse files
rockosovjic23
authored andcommitted
iio:accel:mxc4005: rearrange iio trigger get and register
IIO trigger interface function iio_trigger_get() should be called after iio_trigger_register() (or its devm analogue) strictly, because of iio_trigger_get() acquires module refcnt based on the trigger->owner pointer, which is initialized inside iio_trigger_register() to THIS_MODULE. If this call order is wrong, the next iio_trigger_put() (from sysfs callback or "delete module" path) will dereference "default" module refcnt, which is incorrect behaviour. Fixes: 4719662 ("iio: mxc4005: add data ready trigger for mxc4005") Signed-off-by: Dmitry Rokosov <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent ed30292 commit 9354c22

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iio/accel/mxc4005.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,15 @@ static int mxc4005_probe(struct i2c_client *client,
456456

457457
data->dready_trig->ops = &mxc4005_trigger_ops;
458458
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
459-
indio_dev->trig = data->dready_trig;
460-
iio_trigger_get(indio_dev->trig);
461459
ret = devm_iio_trigger_register(&client->dev,
462460
data->dready_trig);
463461
if (ret) {
464462
dev_err(&client->dev,
465463
"failed to register trigger\n");
466464
return ret;
467465
}
466+
467+
indio_dev->trig = iio_trigger_get(data->dready_trig);
468468
}
469469

470470
return devm_iio_device_register(&client->dev, indio_dev);

0 commit comments

Comments
 (0)