Re: [PATCH] drm: sti: fix device leaks at component probe

Johan Hovold
2025-11-04T11:25:30Z

On Mon, Nov 03, 2025 at 07:56:55PM +0100, Raphaël Gallais-Pou wrote:

> diff --git i/drivers/gpu/drm/sti/sti_vtg.c w/drivers/gpu/drm/sti/sti_vtg.c
> index ee81691b3203..5193196d9291 100644
> --- i/drivers/gpu/drm/sti/sti_vtg.c
> +++ w/drivers/gpu/drm/sti/sti_vtg.c
> @@ -142,7 +142,7 @@ struct sti_vtg {
>
> struct sti_vtg *of_vtg_find(struct device_node *np)
> {
> - struct platform_device *pdev;
> + struct platform_device *pdev __free(put_device) = NULL;

You'd need to declare the variable when looking up pdev, which is one of
the reasons I don't like the cleanup helpers. It also often makes the
code harder to reason about for no good reason (especially with some of
the more esoteric cleanup helpers).

Keep it simple.

Johan