mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure
@ 2026-04-24 11:59 Myeonghun Pak
  2026-04-24 12:11 ` Biju Das
  0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-04-24 11:59 UTC (permalink / raw)
  To: Biju Das
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-renesas-soc,
	linux-kernel, Myeonghun Pak

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;
-- 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure
  2026-04-24 11:59 [PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure Myeonghun Pak
@ 2026-04-24 12:11 ` Biju Das
  0 siblings, 0 replies; 2+ messages in thread
From: Biju Das @ 2026-04-24 12:11 UTC (permalink / raw)
  To: Myeonghun Pak
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-renesas-soc,
	linux-kernel

Hi Myeonghun Pak,

Thanks for the patch.

> -----Original Message-----
> From: Myeonghun Pak <mhun512@gmail.com>
> 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

> 
> 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;
> --

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-24 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-24 11:59 [PATCH] drm/renesas: rz-du: Fix MIPI DSI host leak on probe failure Myeonghun Pak
2026-04-24 12:11 ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®