Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] drm/cdns-dsi: double pm_runtime_put() causes usage counter underflow
--

commit 863c1242b6ff6841137bcc0956d0095317384036
Author: Wentao Liang <[email protected]>

drm/bridge: cdns-dsi: Fix runtime PM leak in cdns_dsi_bridge_atomic_pre_enable()

This commit attempts to fix a runtime PM leak when pm_runtime_get_sync() fails
by adding a call to pm_runtime_put_noidle(). The function then returns early.

> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c 
> b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
> index c3e466ded84ab..dcf7d3e409815 100644
> --- a/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
> +++ b/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
> @@ -733,8 +733,10 @@ static void cdns_dsi_bridge_atomic_pre_enable(struct 
> drm_bridge *bridge,
>        * enable their streams.
>        */
>  
> -     if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0))
> +     if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0)) {
> +             pm_runtime_put_noidle(dsi->base.dev);

[Severity: Medium]
Will this lead to a double-put of the runtime PM reference?

Since cdns_dsi_bridge_atomic_pre_enable() returns void, the DRM core is
unaware that the bridge failed to enable. The atomic commit continues normally,
and when the bridge is later disabled, cdns_dsi_bridge_atomic_post_disable()
is called unconditionally.

If we look at cdns_dsi_bridge_atomic_post_disable(), it executes a second put
during teardown:

static void cdns_dsi_bridge_atomic_post_disable(...)
{
        ...
        pm_runtime_put(dsi->base.dev);
}

Wouldn't this decrement the usage count again and cause a runtime PM usage
counter underflow?

>               return;
> +     }
>  
>       new_bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
>       if (WARN_ON(!new_bridge_state))

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

Reply via email to