* [PATCH v2] drm/bridge: synopsys: dw-dp: return when attach bridge fail
@ 2025-12-31 14:41 Osama Abdelkader
2026-01-02 10:46 ` Luca Ceresoli
0 siblings, 1 reply; 3+ messages in thread
From: Osama Abdelkader @ 2025-12-31 14:41 UTC (permalink / raw)
To: Andy Yan
Cc: Osama Abdelkader, stable, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dmitry Baryshkov, dri-devel, linux-kernel
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")
Cc: stable@vger.kernel.org
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
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(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
index 82aaf74e1bc0..bc311a596dff 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/bridge: synopsys: dw-dp: return when attach bridge fail
2025-12-31 14:41 [PATCH v2] drm/bridge: synopsys: dw-dp: return when attach bridge fail Osama Abdelkader
@ 2026-01-02 10:46 ` Luca Ceresoli
2026-01-02 15:58 ` Osama Abdelkader
0 siblings, 1 reply; 3+ messages in thread
From: Luca Ceresoli @ 2026-01-02 10:46 UTC (permalink / raw)
To: Osama Abdelkader, Andy Yan
Cc: stable, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dmitry Baryshkov, dri-devel, linux-kernel
Hello Osama, Andy Yan,
Andy, a question for you below.
On Wed Dec 31, 2025 at 3:41 PM CET, Osama Abdelkader wrote:
> 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")
> Cc: stable@vger.kernel.org
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> index 82aaf74e1bc0..bc311a596dff 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/bridge: synopsys: dw-dp: return when attach bridge fail
2026-01-02 10:46 ` Luca Ceresoli
@ 2026-01-02 15:58 ` Osama Abdelkader
0 siblings, 0 replies; 3+ messages in thread
From: Osama Abdelkader @ 2026-01-02 15:58 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Andy Yan, stable, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dmitry Baryshkov, dri-devel, linux-kernel
On Fri, Jan 02, 2026 at 11:46:08AM +0100, Luca Ceresoli wrote:
> Hello Osama, Andy Yan,
>
> Andy, a question for you below.
>
> On Wed Dec 31, 2025 at 3:41 PM CET, Osama Abdelkader wrote:
> > 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")
> > Cc: stable@vger.kernel.org
> >
> > Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> > ---
> > 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(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> > index 82aaf74e1bc0..bc311a596dff 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> > @@ -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?
Thanks Luca for the review, I just sent v3.
Best regards,
Osama
>
> Best regards,
> Luca
>
> --
> Luca Ceresoli, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-02 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-31 14:41 [PATCH v2] drm/bridge: synopsys: dw-dp: return when attach bridge fail Osama Abdelkader
2026-01-02 10:46 ` Luca Ceresoli
2026-01-02 15:58 ` Osama Abdelkader
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox