Re: [PATCH v3] media: iris: store formats in the instance
From: Dmitry Baryshkov
Date: Sat Jun 06 2026 - 07:56:28 EST
On Sat, Jun 06, 2026 at 07:47:03PM +0800, Ruoyu Wang wrote:
> The source and destination v4l2_format objects are per-instance state
> with the same lifetime as struct iris_inst, but iris allocates them
> separately during decoder and encoder instance initialization.
>
> Keeping the formats as separate allocations adds failure paths before
> all users can safely dereference them. It also requires every later
> initialization failure to remember to free both objects before the
> instance is released.
>
> Store the formats directly in struct iris_inst and update users to take
> the address of the embedded objects where a pointer is needed. This
> removes the allocation failure path and the matching close-time frees.
>
> Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
> Signed-off-by: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
--
With best wishes
Dmitry