[PATCH 02/35] media: pci: mgb4: use IIO default_trigger

From: Jonathan Cameron

Date: Sun Nov 15 2026 - 20:49:45 EST


From: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>

Set indio_dev->default_trigger rather than taking a reference to the
trigger in probe_trigger(). The IIO core now takes the reference during
iio_device_register().

Previously the reference was taken before iio_triggered_buffer_setup()
set INDIO_BUFFER_TRIGGERED, so a failure in that call leaked the trigger
reference as the IIO core only drops it for devices with triggered modes.

Fixes: 0ab13674a9bd ("media: pci: mgb4: Added Digiteq Automotive MGB4 driver")
Signed-off-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>

---
Ideally I'd like to take this though the IIO tree. There are load of
other changes coming on top of this, ultimately making the
struct iio_dev->trigger opaque to drivers. I can provide an immutable
branch if that is likely to be necessary.

Note as these are just a case of a resource leak in an obscure
error path I haven't been marking them as fixes and it probably
isn't worth backporting them.
---
drivers/media/pci/mgb4/mgb4_trigger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/mgb4/mgb4_trigger.c b/drivers/media/pci/mgb4/mgb4_trigger.c
index 70cad324df60..f48052b76d6d 100644
--- a/drivers/media/pci/mgb4/mgb4_trigger.c
+++ b/drivers/media/pci/mgb4/mgb4_trigger.c
@@ -126,7 +126,7 @@ static int probe_trigger(struct iio_dev *indio_dev, int irq)
if (ret)
goto error_free_irq;

- indio_dev->trig = iio_trigger_get(st->trig);
+ indio_dev->default_trigger = st->trig;

return 0;

--
2.56.1