Skip to content

Commit 10b9c2c

Browse files
rockosovjic23
authored andcommitted
iio:humidity:hts221: 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: e4a70e3 ("iio: humidity: add support to hts221 rh/temp combo device") 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 d710359 commit 10b9c2c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/iio/humidity/hts221_buffer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev)
135135

136136
iio_trigger_set_drvdata(hw->trig, iio_dev);
137137
hw->trig->ops = &hts221_trigger_ops;
138+
139+
err = devm_iio_trigger_register(hw->dev, hw->trig);
140+
138141
iio_dev->trig = iio_trigger_get(hw->trig);
139142

140-
return devm_iio_trigger_register(hw->dev, hw->trig);
143+
return err;
141144
}
142145

143146
static int hts221_buffer_preenable(struct iio_dev *iio_dev)

0 commit comments

Comments
 (0)