Skip to contentSkip to conversation

drm/bridge: synopsys: dw-dp: return when attach bridge fail

PATCH In review Osama Abdelkader 2 participants 3 messages Dec 31, 2025 – Jan 2

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/bridge: synopsys: dw-dp: return when attach bridge fail

When drm_bridge_attach() fails, the function should return an error instead of continuing execution.

Fixes 86eecc3a9c2e ("drm/bridge: synopsys: Add DW DPTX Controller support library")

---
v2:
use concise error message
add Fixes and Cc tags

---
 drivers/gpu/drm/bridge/synopsys/dw-dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-dp.c +1 -1
index 82aaf74e1bc0..bc311a596dff 100644
@@ -2063,7 +2063,7 @@ struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder,
 
 	ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
-		dev_err_probe(dev, ret, "Failed to attach bridge\n");
+		return ERR_PTR(dev_err_probe(dev, ret, "Failed to attach bridge\n"));
 
 	dw_dp_init_hw(dp);
 
Signature · 1 line
2.43.0
reviewer
#1 lore raw

Hello Osama, Andy Yan,

Andy, a question for you below.

Quoted 20 lines · Osama Abdelkader

When drm_bridge_attach() fails, the function should return an error instead of continuing execution.

Fixes 86eecc3a9c2e ("drm/bridge: synopsys: Add DW DPTX Controller support library")

---
v2:
use concise error message
add Fixes and Cc tags

---
 drivers/gpu/drm/bridge/synopsys/dw-dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-dp.c +0 -0
index 82aaf74e1bc0..bc311a596dff 100644

drivers/gpu/drm/bridge/synopsys/dw-dp.c struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder, · line 2066

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-dp.c +1 -1
@@ -2063,7 +2063,7 @@ struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder,
 
 	ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
-		dev_err_probe(dev, ret, "Failed to attach bridge\n");
+		return ERR_PTR(dev_err_probe(dev, ret, "Failed to attach bridge\n"));

Your change looks good now. However there is aanother issue, sorry for not having noticed before.

While reading the dw_dp_bind() code in its entirety I have noticed that on any error after drm_bridge_attach() (and also a drm_bridge_attach() error, with this patch) it returns without undoing the previous actions. This is fine for devm actions, but a problem for non-devm actions, which start at drm_dp_aux_register().

For example, if phy_init() fails, dw_dp_bind() returns without calling drm_dp_aux_unregister(), thus leaking the resources previously allocated by drm_dp_aux_register().

Andy, can you tell whether my analysis is correct?

If it is, this should be fixed before applying this patch. Osama, do you think you can add such a patch in your next iteration?

Best regards,
Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#2 lore raw
Quoted 40 lines · Luca Ceresoli

Hello Osama, Andy Yan,

Andy, a question for you below.

Quoted 20 lines · Osama Abdelkader

When drm_bridge_attach() fails, the function should return an error instead of continuing execution.

Fixes 86eecc3a9c2e ("drm/bridge: synopsys: Add DW DPTX Controller support library")

---
v2:
use concise error message
add Fixes and Cc tags

---
 drivers/gpu/drm/bridge/synopsys/dw-dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-dp.c +0 -0
index 82aaf74e1bc0..bc311a596dff 100644

drivers/gpu/drm/bridge/synopsys/dw-dp.c struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder, · line 2066

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-dp.c +1 -1
@@ -2063,7 +2063,7 @@ struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder,
 
 	ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
-		dev_err_probe(dev, ret, "Failed to attach bridge\n");
+		return ERR_PTR(dev_err_probe(dev, ret, "Failed to attach bridge\n"));

Your change looks good now. However there is aanother issue, sorry for not having noticed before.

While reading the dw_dp_bind() code in its entirety I have noticed that on any error after drm_bridge_attach() (and also a drm_bridge_attach() error, with this patch) it returns without undoing the previous actions. This is fine for devm actions, but a problem for non-devm actions, which start at drm_dp_aux_register().

Quoted 8 lines

For example, if phy_init() fails, dw_dp_bind() returns without calling drm_dp_aux_unregister(), thus leaking the resources previously allocated by drm_dp_aux_register().

Andy, can you tell whether my analysis is correct?

If it is, this should be fixed before applying this patch. Osama, do you think you can add such a patch in your next iteration?

Thanks Luca for the review, I just sent v3.

Best regards,
Osama

Quoted 8 lines

Best regards,
Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com