Re: [PATCH v3] gpu: cdns-mhdp8546: fix call balance of mhdp->clk handling routines

From: Dmitry Baryshkov
Date: Fri Feb 14 2025 - 11:06:12 EST


On Fri, Feb 14, 2025 at 06:46:32PM +0300, Vitalii Mordan wrote:
> If the clock mhdp->clk was not enabled in cdns_mhdp_probe(), it should not
> be disabled in any path.
>
> The return value of clk_prepare_enable() is not checked. If mhdp->clk was
> not enabled, it may be disabled in the error path of cdns_mhdp_probe()
> (e.g., if cdns_mhdp_load_firmware() fails) or in cdns_mhdp_remove() after
> a successful cdns_mhdp_probe() call.
>
> Use the devm_clk_get_enabled() helper function to ensure proper call
> balance for mhdp->clk.
>
> Found by Linux Verification Center (linuxtesting.org) with Klever.
>
> Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP bridge")
> Signed-off-by: Vitalii Mordan <mordan@xxxxxxxxx>
> ---
> v2: Use devm_clk_get_enabled() helper function, as per Dmitry Baryshkov's
> request.
> v3: Describe the paths that lead to unbalanced clock handling routines,
> as requested by Dmitry Baryshkov
>
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>

--
With best wishes
Dmitry