[PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure

Myeonghun Pak posted 1 patch 1 month, 3 weeks ago
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
[PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure
Posted by Myeonghun Pak 1 month, 3 weeks ago
rzg2l_mipi_dsi_probe() registers the MIPI DSI host before allocating the
DCS buffer. If dma_alloc_coherent() fails, probe returns -ENOMEM directly
and leaves the host registered.

The remove callback unregisters the host, but remove is only called after
a successful probe. Add a local unwind path that unregisters the host
before disabling runtime PM on the DCS buffer allocation failure path.

Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
index 29f2b7d24f..309fae1459 100644
--- a/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
+++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
@@ -1476,14 +1476,19 @@ static int rzg2l_mipi_dsi_probe(struct platform_device *pdev)
 
 	dsi->dcs_buf_virt = dma_alloc_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE,
 					       &dsi->dcs_buf_phys, GFP_KERNEL);
-	if (!dsi->dcs_buf_virt)
-		return -ENOMEM;
+	if (!dsi->dcs_buf_virt) {
+		ret = -ENOMEM;
+		goto err_host_unregister;
+	}
 
 	return 0;
 
 err_phy:
 	dsi->info->dphy_exit(dsi);
 	pm_runtime_put(dsi->dev);
+	goto err_pm_disable;
+err_host_unregister:
+	mipi_dsi_host_unregister(&dsi->host);
 err_pm_disable:
 	pm_runtime_disable(dsi->dev);
 	return ret;
--