Skip to contentSkip to conversation

drm: renesas: rz-du: mipi_dsi: Fix return path on error

PATCH Superseded Chris Brandt 3 participants 6 messages Apr 17 – Apr 21

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: renesas: rz-du: mipi_dsi: Fix return path on error

In case of error, we should unwind correctly.

Fixes 6f392f371650 ("drm: renesas: rz-du: Implement MIPI DSI host transfers")
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +4 -2
index 29f2b7d24fe5..92ea26ce723f 100644
@@ -1476,8 +1476,10 @@ 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_pm_disable;
+	}
 
 	return 0;
 
Signature · 1 line
2.52.0
Acked-by on v1 1/1
#1 lore raw

Hi Chris,

Quoted 5 lines · On Fri, 17 Apr 2026 10:02:31 -0400 Chris Brandt <[email protected]>…

In case of error, we should unwind correctly.

Fixes 6f392f371650 ("drm: renesas: rz-du: Implement MIPI DSI host transfers")
Quoted 25 lines
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +4 -2
index 29f2b7d24fe5..92ea26ce723f 100644
@@ -1476,8 +1476,10 @@ 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_pm_disable;
+	}
 
 	return 0;
 
Signature · 1 line
2.52.0
Signature · 1 line
Hugo Villeneuve
#2 lore raw
In reply to Chris Brandt

Hi Chris,

Quoted 5 lines · Chris Brandt

In case of error, we should unwind correctly.

Fixes 6f392f371650 ("drm: renesas: rz-du: Implement MIPI DSI host transfers")

Thanks for your patch!

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c static int rzg2l_mipi_dsi_probe(struct platform_device *pdev) · line 1481

Quoted 11 lines
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +3 -2
@@ -1476,8 +1476,10 @@ 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_pm_disable;

Shouldn't you call mipi_dsi_host_unregister(&dsi->host) first?

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c static int rzg2l_mipi_dsi_probe(struct platform_device *pdev) · line 1485

Quoted 4 lines
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +1 -0
+       }
 
        return 0;
 

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#3 lore raw

Hi Geert,

Quoted 7 lines · Geert Uytterhoeven

drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c static int rzg2l_mipi_dsi_probe(struct platform_device *pdev) · line 1481

Quoted 5 lines
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +3 -2
-       if (!dsi->dcs_buf_virt)
-               return -ENOMEM;
+       if (!dsi->dcs_buf_virt) {
+               ret = -ENOMEM;
+               goto err_pm_disable;

Shouldn't you call mipi_dsi_host_unregister(&dsi->host) first?

Good point.

Since it doesn't really matter -when- that memory is allocated in probe, maybe I'll just keep the original lines, just move them earlier in the function when all the other resources are being allocated using devm_xxx.

Then I don't have to worry about the it anymore.

Thanks,
Chris

#4 lore raw

Hi Geert,

Quoted 4 lines · Chris Brandt

Since it doesn't really matter -when- that memory is allocated in probe, maybe I'll just keep the original lines, just move them earlier in the function when all the other resources are being allocated using devm_xxx.

Then I don't have to worry about the it anymore.

Oh wait, I guess I also need to change from calling dma_alloc_coherent() to dmam_alloc_coherent() so it will automatically unwind.

And then, I can remove the call to dma_free_coherent() in rzg2l_mipi_dsi_remove() as well.

Does this sound like a better idea?

Chris

#5 lore raw

Hi Chris,

Quoted 11 lines · Chris Brandt
Quoted 4 lines · Chris Brandt

Since it doesn't really matter -when- that memory is allocated in probe, maybe I'll just keep the original lines, just move them earlier in the function when all the other resources are being allocated using devm_xxx.

Then I don't have to worry about the it anymore.

Oh wait, I guess I also need to change from calling dma_alloc_coherent() to dmam_alloc_coherent() so it will automatically unwind.

And then, I can remove the call to dma_free_coherent() in rzg2l_mipi_dsi_remove() as well.

Does this sound like a better idea?

Sounds fine to me!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds