Skip to content

Commit 8878780

Browse files
AngeloGioacchino Del Regnosuperna9999
authored andcommitted
drm/bridge: panel: Fix device link for DRM_BRIDGE_ATTACH_NO_CONNECTOR
When external bridges are attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, the panel bridge may also get the same flag, but in the .attach() callback for the panel bridge a device link is added only when this flag is not present; To make things worse, the .detach() callback tries to delete the device link unconditionally and without checking if it was created in the first place, crashing the kernel with a NULL pointer kernel panic upon calling panel_bridge_detach(). Fix that by moving the device_link_add() call before checking if the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is present. Fixes: 199cf07 ("drm/bridge: panel: Add a device link between drm device and panel device") Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Liu Ying <victor.liu@nxp.com> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230920082727.57729-1-angelogioacchino.delregno@collabora.com
1 parent 1c7a387 commit 8878780

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/gpu/drm/bridge/panel.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
6767
struct drm_device *drm_dev = bridge->dev;
6868
int ret;
6969

70-
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
71-
return 0;
72-
73-
if (!bridge->encoder) {
74-
DRM_ERROR("Missing encoder\n");
75-
return -ENODEV;
76-
}
77-
7870
panel_bridge->link = device_link_add(drm_dev->dev, panel->dev,
7971
DL_FLAG_STATELESS);
8072
if (!panel_bridge->link) {
@@ -83,6 +75,15 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
8375
return -EINVAL;
8476
}
8577

78+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
79+
return 0;
80+
81+
if (!bridge->encoder) {
82+
DRM_ERROR("Missing encoder\n");
83+
device_link_del(panel_bridge->link);
84+
return -ENODEV;
85+
}
86+
8687
drm_connector_helper_add(connector,
8788
&panel_bridge_connector_helper_funcs);
8889

0 commit comments

Comments
 (0)