Re: [PATCH v3] iio: trigger: use put_device() in viio_trigger_alloc() error path

Nuno Sá
2026-02-17T13:50:27Z

On Mon, 2026-02-16 at 09:45 +0100, Salah Triki wrote:
> Hi Andy,
>
> You are absolutely right. My previous version (v3) was logically flawed as
> it could trigger the release callback before the necessary fields were
> initialized, leading to an unsafe irq_free_descs() call.
>
> Since I don't have the physical hardware to perform runtime injection
> tests,I relied on manual code path analysis and clearly failed to account
> for the side effects of put_device().
>
> I'm sending a v4 which takes the safer approach: moving
> device_initialize() after all potential failure points. This way, we can
> safely use kfree() and irq_free_descs() in the error path without
> involving the device lifecycle prematurely.
>
> Thank you for the catch.

Please just use the same approach Andy did for iio_device_alloc(). I posted links (in one of your
versions) to that and for the discussion we already had on this same function some time ago.

- Nuno Sá