[PATCH v7 04/23] drm: bridge: dw_hdmi: Hold bridge ref until connector cleanup
Jonas Karlman
jonas at kwiboo.se
Tue May 19 08:18:40 PDT 2026
Hello Luca,
On 5/19/2026 2:06 PM, Luca Ceresoli wrote:
> On Mon, 18 May 2026 18:01:40 +0000, Jonas Karlman <jonas at kwiboo.se> wrote:
>
> Hello Jonas,
>
>>
>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>> index b7bfc0e9a6b2..9d795c550f8a 100644
>> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>> @@ -2600,10 +2609,14 @@ static int dw_hdmi_connector_create(struct dw_hdmi *hdmi)
>>
>> drm_connector_helper_add(connector, &dw_hdmi_connector_helper_funcs);
>>
>> - drm_connector_init_with_ddc(hdmi->bridge.dev, connector,
>> - &dw_hdmi_connector_funcs,
>> - DRM_MODE_CONNECTOR_HDMIA,
>> - hdmi->ddc);
>> + ret = drm_connector_init_with_ddc(hdmi->bridge.dev, connector,
>> + &dw_hdmi_connector_funcs,
>> + DRM_MODE_CONNECTOR_HDMIA,
>> + hdmi->ddc);
>> + if (ret)
>> + return ret;
>> +
>> + drm_bridge_get(&hdmi->bridge);
>
> I'm not fully following the code paths, but both the report and the fix
> make sense to me. Only I'd move the drm_bridge_get() before
> drm_connector_init_with_ddc(), to avoid a short window where no reference
> is held and the bridge might be destroyed before drm_bridge_get() is
> called. I'm not sure this can happen, but it's better to write the code in
> a way that clearly makes it impossible.
dw_hdmi_connector_create() is only called from dw_hdmi_bridge_attach()
so the bridge should already have a ref for the lifetime of this call.
I explicitly chose the placement after drm_connector_init_with_ddc()
to ensure ref count is correctly balanced without having to add a
drm_bridge_put() call in any error path. I.e. connector destroy() is
only called when drm_connector_init_with_ddc() succeeds.
This code/call is also planned to be removed in a future series, so I do
not think moving drm_bridge_get() is necessary unless you think we need
to protect against possible bad behavior from DRM core?
Regards,
Jonas
>
> Otherwise looks good.
>
> Luca
>
More information about the Linux-rockchip
mailing list