[PATCH] iio: gyro: mpu3050: use devm_iio_trigger_register()

Stepan Ionichev posted 1 patch 4 days, 12 hours ago
drivers/iio/gyro/mpu3050-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] iio: gyro: mpu3050: use devm_iio_trigger_register()
Posted by Stepan Ionichev 4 days, 12 hours ago
mpu3050_trigger_probe() allocates the DRDY trigger with
devm_iio_trigger_alloc() but registers it with plain
iio_trigger_register(). mpu3050_common_remove() never calls
iio_trigger_unregister(), so on module unload the trigger stays
in the global trigger list while its memory is later released by
devm, leaving a dangling entry.

Switch to devm_iio_trigger_register() so the registration is
undone in the same devm scope as the allocation.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
 drivers/iio/gyro/mpu3050-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index d84e04e4b..596919318 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -1127,7 +1127,7 @@ static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq)
 	mpu3050->trig->ops = &mpu3050_trigger_ops;
 	iio_trigger_set_drvdata(mpu3050->trig, indio_dev);
 
-	ret = iio_trigger_register(mpu3050->trig);
+	ret = devm_iio_trigger_register(&indio_dev->dev, mpu3050->trig);
 	if (ret)
 		goto err_iio_trigger;
 
-- 
2.43.0
Re: [PATCH] iio: gyro: mpu3050: use devm_iio_trigger_register()
Posted by Stepan Ionichev 4 days, 11 hours ago
Just noticed Li Xinyu sent the same fix earlier today:
https://lore.kernel.org/all/20260520032447.1683688-1-xinyuili@126.com/

Please drop this one and use Li's; I should have checked lore before
sending. Sorry for the duplication.

Stepan