Re: [PATCH v3 04/29] media: v4l2-subdev: Allow releasing frame descriptors on return

Frank Li <[email protected]>
Newsgroups org.kernel.vger.linux-media
Message-ID <aoyqu4MGBd9tXPDe@lizhi-Precision-Tower-5810>
On Mon, Aug 24, 2026 at 03:14:26PM +0300, Sakari Ailus wrote:
> Use DEFINE_FREE() to allow using __free() to release frame descriptors
> using v4l2_subdev_free_frame_desc().
>
> Signed-off-by: Sakari Ailus <[email protected]>
> ---

Reviewed-by: Frank Li <[email protected]>

>  include/media/v4l2-subdev.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index e7127953ac22..c10ca3f5d979 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -1798,6 +1798,11 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd,
>   * for each frame descriptor obtained by calling this function using
>   * v4l2_subdev_free_frame_desc().
>   *
> + * Use __free() to release the frame descriptor automatically::
> + *
> + *    struct v4l2_mbus_frame_desc *desc __free(v4l2_subdev_free_frame_desc) =
> + *            v4l2_subdev_get_frame_desc(sd, pad, desc);
> + *
>   * Return: The frame descriptor on success or a negative error code on failure.
>   */
>  struct v4l2_mbus_frame_desc *
> @@ -1812,6 +1817,10 @@ v4l2_subdev_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
>   */
>  void v4l2_subdev_free_frame_desc(struct v4l2_mbus_frame_desc *desc);
>
> +DEFINE_FREE(v4l2_subdev_free_frame_desc, struct v4l2_mbus_frame_desc *, \
> +	    if (!IS_ERR_OR_NULL(_T))					\
> +		    v4l2_subdev_free_frame_desc(_T))
> +
>  #endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */
>
>  #endif /* CONFIG_MEDIA_CONTROLLER */
> --
> 2.47.3
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.