Re: [PATCH 00/35] iio: closing default trigger handling leaks

From: Joshua Crofts

Date: Wed Nov 18 2026 - 03:46:54 EST


On Mon, 16 Nov 2026 01:47:48 +0000
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> From: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>
>
> Note this is compile tested only! I definitely want a few people
> to test that I didn't break everything.
>
> This is the first part of what I think is a long term solution to the
> currently really fragile ordering constraints around setting default
> triggers. Today these are set by iio_dev->trig = iio_trigger_get(trig).
> The reference is only released on the iio_dev.release callback and
> only if we have set the mode to include one that means there might be
> a trigger set. That mode set only occurs when a buffer is registered.
> Thus trigger release only works if we have already registered a buffer.
>
> One solution would be to reorder so that the default trigger is always
> set after the buffer registration (we have had various recent proposed
> patches to do that for individual drivers) but that is non obvious and
> fragile.
>
> The solution here is easier to reason about. Decouple the setting
> of the default trigger from the acquisition of a reference. Thus
> we can acquire the reference in iio_device_register() when we know
> all the conditions for it's release have been achieved.
> So that's all we do in this part 1 series.
>
> Part 2 will address immutable triggers and those that are effectively
> immutable but predate that logic. That is those that set a one to one
> relationship between device and trigger. That change is rather less
> mechanical than this one and 35 patches is really a bit big anyway
> even if most of them are small!
>
> Part 3 and beyond will move to a situation where the iio_dev->trig
> will become opaque. That should stop anyone manipulating that directly.
> I have a few related cunning plans to test out before we get to that,
> not because the particular challenge is hard, but because they will
> trample on the same code.
>

I went through the set and only have one nit (an incorrect fixes tag),
otherwise seems fine.

Reviewed-by: Joshua Crofts <crofts@xxxxxxxxxx>

--
Kind regards,
Joshua Crofts