drm/bridge: dw-mipi-dsi: Fix bridge leak when host attach fails
Subsystems (3)
PATCH v2 1/1 drm/bridge: dw-mipi-dsi: Fix bridge leak when host attach fails
dw_mipi_dsi_host_attach() and dw_mipi_dsi2_host_attach() call drm_bridge_add() before pdata->host_ops->attach(). If attach fails, the bridge stayed registered without drm_bridge_remove(), leaking the bridge reference and leaving the device on the global bridge list.
---
v2:
- Use drm_bridge_remove only in the error paths
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 6 +++++- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +5 -1
@@ -345,10 +345,14 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,if (pdata->host_ops && pdata->host_ops->attach) { ret = pdata->host_ops->attach (pdata->priv_data, device);if (ret <0 ) -return ret; + goto err_remove_bridge; }return 0 ; + +err_remove_bridge: +drm_bridge_remove (&dsi->bridge); +return ret; } static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c +5 -1
@@ -540,10 +540,14 @@ static int dw_mipi_dsi2_host_attach(struct mipi_dsi_host *host,if (pdata->host_ops && pdata->host_ops->attach) { ret = pdata->host_ops->attach (pdata->priv_data, device);if (ret <0 ) -return ret; + goto err_remove_bridge; }return 0 ; + +err_remove_bridge: +drm_bridge_remove (&dsi2->bridge); +return ret; } static int dw_mipi_dsi2_host_detach(struct mipi_dsi_host *host,
Signature · 1 line
2.43.0
Quoted 8 lines · Osama Abdelkader
dw_mipi_dsi_host_attach()anddw_mipi_dsi2_host_attach()calldrm_bridge_add()beforepdata->host_ops->attach(). If attach fails, the bridge stayed registered withoutdrm_bridge_remove(), leaking the bridge reference and leaving the device on the global bridge list.Fixes 90910a651123 ("drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach")Fixes 0d6d86253fef ("drm/bridge/synopsys: Add MIPI DSI2 host controller bridge")Signed-off-by Osama Abdelkader <[email protected]>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 4 lines · Osama Abdelkader
dw_mipi_dsi_host_attach()anddw_mipi_dsi2_host_attach()calldrm_bridge_add()beforepdata->host_ops->attach(). If attach fails, the bridge stayed registered withoutdrm_bridge_remove(), leaking the bridge reference and leaving the device on the global bridge list.
Applied, thanks!
[1/1] drm/bridge: dw-mipi-dsi: Fix bridge leak when host attach fails
commit: be19b43f92fae4794f271ed9e338bdbcfa725aa2
Best regards,
Signature · 1 line
Luca Ceresoli <[email protected]>