Skip to contentSkip to conversation

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

PATCH In review Myeonghun Pak 2 participants 3 messages Apr 24 – Apr 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +7 -2
index 29f2b7d24f..309fae1459 100644
@@ -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;
maintainer
#1 lore raw

Hi Myeonghun Pak,

Thanks for the patch.

Quoted 11 lines

-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: 24 April 2026 12:59
Subject: [PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure

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.

A similar patch [1] already posted

[1] https://lore.kernel.org/linux-renesas-soc/TY3PR01MB113464115454EB533EE670E81862B2@TY3PR01MB11346.jpnprd01.prod.outlook.com/T/#m3c56399b78f8661ff2b5bfc2f2d8a1364a9ebf7d

Cheers,
Biju

Quoted 34 lines
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/renesas/rz- renamed from drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +0 -0

du/rzg2l_mipi_dsi.c
index 29f2b7d24f..309fae1459 100644

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +7 -3
@@ -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;
--
#2 lore raw

Hi Biju,

Thank you for the quick reply.

I've confirmed that a similar patch has already been posted.

Thanks,
Myeonghun Pak

2026년 4월 24일 (금) 오후 9:11, Biju Das <[email protected]>님이 작성:

Quoted 69 lines

Hi Myeonghun Pak,

Thanks for the patch.

Quoted 4 lines

-----Original Message-----
From: Myeonghun Pak <[email protected]>
Sent: 24 April 2026 12:59
Subject: [PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe

failure

Quoted 2 lines

rzg2l_mipi_dsi_probe() registers the MIPI DSI host before allocating the

DCS buffer. If

Quoted 1 line

dma_alloc_coherent() fails, probe returns -ENOMEM directly and leaves

the host registered.

Quoted 2 lines

The remove callback unregisters the host, but remove is only called

after a successful probe. Add a

Quoted 1 line

local unwind path that unregisters the host before disabling runtime PM

on the DCS buffer allocation

Quoted 1 line

failure path.

A similar patch [1] already posted

[1]
https://lore.kernel.org/linux-renesas-soc/TY3PR01MB113464115454EB533EE670E81862B2@TY3PR01MB11346.jpnprd01.prod.outlook.com/T/#m3c56399b78f8661ff2b5bfc2f2d8a1364a9ebf7d

Cheers,
Biju

Review

Quoted 7 lines
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/renesas/rz-

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c static int rzg2l_mipi_dsi_probe(struct

Quoted 5 lines

du/rzg2l_mipi_dsi.c
index 29f2b7d24f..309fae1459 100644

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +0 -0
@@ -1476,14 +1476,19 @@ static int rzg2l_mipi_dsi_probe(struct

platform_device *pdev)

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c static int rzg2l_mipi_dsi_probe(struct · line 1476

Quoted 2 lines
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +0 -0
      dsi->dcs_buf_virt = dma_alloc_coherent(dsi->host.dev,

RZG2L_DCS_BUF_SIZE,

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c static int rzg2l_mipi_dsi_probe(struct · line 1477

Quoted 1 line
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +0 -0
                                             &dsi->dcs_buf_phys,

GFP_KERNEL);

Quoted 19 lines
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +7 -3
-     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;
--