Skip to content

Commit d710359

Browse files
rockosovjic23
authored andcommitted
iio:chemical:ccs811: 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: f1f065d ("iio: chemical: ccs811: Add support for data ready trigger") 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 9354c22 commit d710359

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iio/chemical/ccs811.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,11 @@ static int ccs811_probe(struct i2c_client *client,
499499

500500
data->drdy_trig->ops = &ccs811_trigger_ops;
501501
iio_trigger_set_drvdata(data->drdy_trig, indio_dev);
502-
indio_dev->trig = data->drdy_trig;
503-
iio_trigger_get(indio_dev->trig);
504502
ret = iio_trigger_register(data->drdy_trig);
505503
if (ret)
506504
goto err_poweroff;
505+
506+
indio_dev->trig = iio_trigger_get(data->drdy_trig);
507507
}
508508

509509
ret = iio_triggered_buffer_setup(indio_dev, NULL,

0 commit comments

Comments
 (0)