Re: [PATCH v4] iio: core: Clean up device correctly on viio_trigger_alloc() failure

From: David Lechner

Date: Sat Feb 21 2026 - 12:07:23 EST


On 2/21/26 1:32 AM, Salah Triki wrote:
> Once we called device_initialize() we have to call put_device()
> on it. Refactor the code to make it in the right order.

This could be a bit more clear. Something like ...

Move device_initialize() after all error paths in viio_trigger_alloc().
Previously, we should have been calling put_device() on any error path
after device_initialize(), but failed to do so.

Rather than adding put_device(), we can just move device_initialize()
to avoid needing to unwind it on error.

Additional trig->dev initialization is also moved with this just to
keep the code organized.


>

Did we decide this doesn't need a Fixes: tag?

> Signed-off-by: Salah Triki <salah.triki@xxxxxxxxx>
> ---
No need to send a new revision for this right away. If Jonathan is
in the mood, he might fix it up for you.

With the commit message improved:

Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>