iio:humidity:hts221: rearrange iio trigger get and register
authorDmitry Rokosov <DDRokosov@sberdevices.ru>
Tue, 24 May 2022 18:14:46 +0000 (18:14 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 19 Jun 2022 16:22:49 +0000 (17:22 +0100)
commit10b9c2c33ac706face458feab8965f11743c98c0
tree4fb1babd63918356a3f69d6a58d252c098d97532
parentd710359c0b445e8c03e24f19ae2fb79ce7282260
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: e4a70e3e7d84 ("iio: humidity: add support to hts221 rh/temp combo device")
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220524181150.9240-6-ddrokosov@sberdevices.ru
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/humidity/hts221_buffer.c