Commit be19b43f authored by Osama Abdelkader's avatar Osama Abdelkader Committed by Luca Ceresoli
Browse files

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.

Fixes: 90910a65 ("drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach")
Fixes: 0d6d8625 ("drm/bridge/synopsys: Add MIPI DSI2 host controller bridge")
Signed-off-by: default avatarOsama Abdelkader <osama.abdelkader@gmail.com>
Reviewed-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://patch.msgid.link/20260403145208.15890-1-osama.abdelkader@gmail.com


Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
parent ad3ac32a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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,
+5 −1
Original line number Diff line number Diff line
@@ -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,