[PATCH v4] drm/bridge: synopsys: dw-dp: Check return value of devm_drm_bridge_add() in dw_dp_bind()

Chen Ni posted 1 patch 2 days, 4 hours ago
drivers/gpu/drm/bridge/synopsys/dw-dp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH v4] drm/bridge: synopsys: dw-dp: Check return value of devm_drm_bridge_add() in dw_dp_bind()
Posted by Chen Ni 2 days, 4 hours ago
Return the value of devm_drm_bridge_add() in order to propagate the
error properly, if it fails due to resource allocation failure or bridge
registration failure.

This ensures that the bind function fails safely rather than proceeding
with a potentially incomplete bridge setup.

Fixes: b726970486d8 ("drm/bridge: synopsys: dw-dp: add bridge before attaching")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Reviewed-by: Andy Yan <andyshrk@163.com>
---
Changes in v4:
- Add Reviewed-by tag from Andy Yan <andyshrk@163.com>

Changes in v3:
- Remove dev_err_probe() logging

Changes in v2:
- Use ERR_PTR() instead of dev_err_ptr_probe()
---
 drivers/gpu/drm/bridge/synopsys/dw-dp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
index 432342452484..07f7a2e0d9f2 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
@@ -2049,7 +2049,9 @@ struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder,
 	bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
 	bridge->ycbcr_420_allowed = true;
 
-	devm_drm_bridge_add(dev, bridge);
+	ret = devm_drm_bridge_add(dev, bridge);
+	if (ret)
+		return ERR_PTR(ret);
 
 	dp->aux.dev = dev;
 	dp->aux.drm_dev = encoder->dev;
-- 
2.25.1
Re: [PATCH v4] drm/bridge: synopsys: dw-dp: Check return value of devm_drm_bridge_add() in dw_dp_bind()
Posted by Markus Elfring 1 day, 19 hours ago
> Return the value of devm_drm_bridge_add() in order to propagate the
> error properly, if it fails due to resource allocation failure or bridge
> registration failure.
…

* Were any source code analysis tools involved here?

* See also once more:
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v6.19-rc8#n34


Regards,
Markus
Re: [PATCH v4] drm/bridge: synopsys: dw-dp: Check return value of devm_drm_bridge_add() in dw_dp_bind()
Posted by Luca Ceresoli 2 days ago
Hello Chen, Andy,

On Fri Feb 6, 2026 at 5:06 AM CET, Chen Ni wrote:
> Return the value of devm_drm_bridge_add() in order to propagate the
> error properly, if it fails due to resource allocation failure or bridge
> registration failure.
>
> This ensures that the bind function fails safely rather than proceeding
> with a potentially incomplete bridge setup.
>
> Fixes: b726970486d8 ("drm/bridge: synopsys: dw-dp: add bridge before attaching")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> Reviewed-by: Andy Yan <andyshrk@163.com>
> ---
> Changes in v4:
> - Add Reviewed-by tag from Andy Yan <andyshrk@163.com>

As far as I can see Andy reviewed v2, not this version.

Andy, if you are OK with this version it'd be great if you could tell it
clearly with a Reviewed-by, possibly on v3 which has the exact same diff
and commit message.

Luca

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