Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] Unbalanced clock disable in `ltdc_load()` due to incorrect error 
path cleanup.
--

--- Patch [1]: [PATCH] drm/stm/ltdc: Fix clock cleanup error handling ---
commit 12fe618c7882264e51fac6ed9a7b1ab9994cdfbe
Author: Hongling Zeng <[email protected]>

drm/stm/ltdc: Fix clock cleanup error handling

This commit fixes resource leaks by ensuring clocks are properly disabled and
unprepared when subsequent clock preparations fail in ltdc_resume() and
ltdc_load().

> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 95fcfa48d8be3..ead9e87bd7192 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
[ ... ]
> @@ -1962,7 +1971,7 @@ int ltdc_load(struct drm_device *ddev)
>               ret = clk_prepare_enable(ldev->bus_clk);
>               if (ret) {
>                       drm_err(ddev, "Unable to prepare bus clock\n");
> -                     return ret;
> +                     goto err;
>               }
>       }
>  

[Severity: Medium]
Does this new error path cause an unbalanced clock disable?

If clk_prepare_enable() fails here in ltdc_load(), the pointer ldev->bus_clk
is already set (and non-NULL), but the clock was not successfully enabled. 

By jumping to the 'err' label at the end of ltdc_load():

err:
        clk_disable_unprepare(ldev->pixel_clk);

        if (ldev->bus_clk)
                clk_disable_unprepare(ldev->bus_clk);

Won't this cleanup code unconditionally call clk_disable_unprepare() on a clock
that failed to enable? It seems this would decrement the prepare/enable
counters below their actual values and trigger a WARN in the common clock
framework.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to