mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: renesas: rz-ssi: Clean up on error in probe()
@ 2025-01-15  6:55 Dan Carpenter
  2025-01-17 11:51 ` Claudiu Beznea
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-01-15  6:55 UTC (permalink / raw)
  To: Biju Das
  Cc: Lad Prabhakar, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, linux-sound, linux-renesas-soc, linux-kernel,
	kernel-janitors

Call rz_ssi_release_dma_channels() on these error paths to clean up from
rz_ssi_dma_request().

Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 sound/soc/renesas/rz-ssi.c | 42 ++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/sound/soc/renesas/rz-ssi.c b/sound/soc/renesas/rz-ssi.c
index 3a0af4ca7ab6..4b3016282717 100644
--- a/sound/soc/renesas/rz-ssi.c
+++ b/sound/soc/renesas/rz-ssi.c
@@ -1150,35 +1150,47 @@ static int rz_ssi_probe(struct platform_device *pdev)
 		ssi->irq_rx = platform_get_irq_byname(pdev, "dma_rx");
 		if (ssi->irq_tx == -ENXIO && ssi->irq_rx == -ENXIO) {
 			ssi->irq_rt = platform_get_irq_byname(pdev, "dma_rt");
-			if (ssi->irq_rt < 0)
-				return ssi->irq_rt;
+			if (ssi->irq_rt < 0) {
+				ret = ssi->irq_rt;
+				goto err_release_dma_chs;
+			}
 
 			ret = devm_request_irq(dev, ssi->irq_rt,
 					       &rz_ssi_interrupt, 0,
 					       dev_name(dev), ssi);
-			if (ret < 0)
-				return dev_err_probe(dev, ret,
-						     "irq request error (dma_rt)\n");
+			if (ret < 0) {
+				dev_err_probe(dev, ret,
+					      "irq request error (dma_rt)\n");
+				goto err_release_dma_chs;
+			}
 		} else {
-			if (ssi->irq_tx < 0)
-				return ssi->irq_tx;
+			if (ssi->irq_tx < 0) {
+				ret = ssi->irq_tx;
+				goto err_release_dma_chs;
+			}
 
-			if (ssi->irq_rx < 0)
-				return ssi->irq_rx;
+			if (ssi->irq_rx < 0) {
+				ret = ssi->irq_rx;
+				goto err_release_dma_chs;
+			}
 
 			ret = devm_request_irq(dev, ssi->irq_tx,
 					       &rz_ssi_interrupt, 0,
 					       dev_name(dev), ssi);
-			if (ret < 0)
-				return dev_err_probe(dev, ret,
-						"irq request error (dma_tx)\n");
+			if (ret < 0) {
+				dev_err_probe(dev, ret,
+					      "irq request error (dma_tx)\n");
+				goto err_release_dma_chs;
+			}
 
 			ret = devm_request_irq(dev, ssi->irq_rx,
 					       &rz_ssi_interrupt, 0,
 					       dev_name(dev), ssi);
-			if (ret < 0)
-				return dev_err_probe(dev, ret,
-						"irq request error (dma_rx)\n");
+			if (ret < 0) {
+				dev_err_probe(dev, ret,
+					      "irq request error (dma_rx)\n");
+				goto err_release_dma_chs;
+			}
 		}
 	}
 
-- 
2.45.2


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

* Re: [PATCH] ASoC: renesas: rz-ssi: Clean up on error in probe()
  2025-01-15  6:55 [PATCH] ASoC: renesas: rz-ssi: Clean up on error in probe() Dan Carpenter
@ 2025-01-17 11:51 ` Claudiu Beznea
  2025-01-20 10:32   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Claudiu Beznea @ 2025-01-17 11:51 UTC (permalink / raw)
  To: Dan Carpenter, Biju Das
  Cc: Lad Prabhakar, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, linux-sound, linux-renesas-soc, linux-kernel,
	kernel-janitors

Hi, Dan,

On 15.01.2025 08:55, Dan Carpenter wrote:
> Call rz_ssi_release_dma_channels() on these error paths to clean up from
> rz_ssi_dma_request().
> 
> Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  sound/soc/renesas/rz-ssi.c | 42 ++++++++++++++++++++++++--------------
>  1 file changed, 27 insertions(+), 15 deletions(-)
> 
> diff --git a/sound/soc/renesas/rz-ssi.c b/sound/soc/renesas/rz-ssi.c
> index 3a0af4ca7ab6..4b3016282717 100644
> --- a/sound/soc/renesas/rz-ssi.c
> +++ b/sound/soc/renesas/rz-ssi.c
> @@ -1150,35 +1150,47 @@ static int rz_ssi_probe(struct platform_device *pdev)
>  		ssi->irq_rx = platform_get_irq_byname(pdev, "dma_rx");
>  		if (ssi->irq_tx == -ENXIO && ssi->irq_rx == -ENXIO) {
>  			ssi->irq_rt = platform_get_irq_byname(pdev, "dma_rt");
> -			if (ssi->irq_rt < 0)
> -				return ssi->irq_rt;
> +			if (ssi->irq_rt < 0) {
> +				ret = ssi->irq_rt;
> +				goto err_release_dma_chs;
> +			}
>  
>  			ret = devm_request_irq(dev, ssi->irq_rt,
>  					       &rz_ssi_interrupt, 0,
>  					       dev_name(dev), ssi);
> -			if (ret < 0)
> -				return dev_err_probe(dev, ret,
> -						     "irq request error (dma_rt)\n");
> +			if (ret < 0) {
> +				dev_err_probe(dev, ret,
> +					      "irq request error (dma_rt)\n");
> +				goto err_release_dma_chs;
> +			}
>  		} else {
> -			if (ssi->irq_tx < 0)
> -				return ssi->irq_tx;
> +			if (ssi->irq_tx < 0) {
> +				ret = ssi->irq_tx;
> +				goto err_release_dma_chs;
> +			}
>  
> -			if (ssi->irq_rx < 0)
> -				return ssi->irq_rx;
> +			if (ssi->irq_rx < 0) {
> +				ret = ssi->irq_rx;
> +				goto err_release_dma_chs;
> +			}
>  
>  			ret = devm_request_irq(dev, ssi->irq_tx,
>  					       &rz_ssi_interrupt, 0,
>  					       dev_name(dev), ssi);
> -			if (ret < 0)
> -				return dev_err_probe(dev, ret,
> -						"irq request error (dma_tx)\n");
> +			if (ret < 0) {
> +				dev_err_probe(dev, ret,
> +					      "irq request error (dma_tx)\n");
> +				goto err_release_dma_chs;
> +			}
>  
>  			ret = devm_request_irq(dev, ssi->irq_rx,
>  					       &rz_ssi_interrupt, 0,
>  					       dev_name(dev), ssi);
> -			if (ret < 0)
> -				return dev_err_probe(dev, ret,
> -						"irq request error (dma_rx)\n");
> +			if (ret < 0) {
> +				dev_err_probe(dev, ret,
> +					      "irq request error (dma_rx)\n");
> +				goto err_release_dma_chs;
> +			}
>  		}
>  	}

The code block ending here is entered only if !rz_ssi_is_dma_enabled(). If
that is true there are no DMA channel to be released. Maybe better would be
to move this code block on the failure path of the rz_ssi_dma_request() as
also proposed here:
https://lore.kernel.org/all/CAMuHMdU+_NuLp2FuwwcLfJRe2ssMtp=z7fqcsANgYfFehTNJGg@mail.gmail.com/

Thank you,
Claudiu

>  


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

* Re: [PATCH] ASoC: renesas: rz-ssi: Clean up on error in probe()
  2025-01-17 11:51 ` Claudiu Beznea
@ 2025-01-20 10:32   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-01-20 10:32 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: Biju Das, Lad Prabhakar, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, linux-sound, linux-renesas-soc,
	linux-kernel, kernel-janitors

On Fri, Jan 17, 2025 at 01:51:55PM +0200, Claudiu Beznea wrote:
> > -			if (ret < 0)
> > -				return dev_err_probe(dev, ret,
> > -						"irq request error (dma_rx)\n");
> > +			if (ret < 0) {
> > +				dev_err_probe(dev, ret,
> > +					      "irq request error (dma_rx)\n");
> > +				goto err_release_dma_chs;
> > +			}
> >  		}
> >  	}
> 
> The code block ending here is entered only if !rz_ssi_is_dma_enabled(). If
> that is true there are no DMA channel to be released. Maybe better would be
> to move this code block on the failure path of the rz_ssi_dma_request() as
> also proposed here:
> https://lore.kernel.org/all/CAMuHMdU+_NuLp2FuwwcLfJRe2ssMtp=z7fqcsANgYfFehTNJGg@mail.gmail.com/
> 

Aw crud...  Thanks for the review.  Cut and pasting the code seems like
probably the right answer.  It's not a hard patch to write, but I don't
have the hardware so I can't test it.  The existing ordering feels tricky
enough that there is probably a reason for it which I just can't see off
the top of my head...

Let me think about this some more.

regards,
dan carpenter

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

end of thread, other threads:[~2025-01-20 10:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-15  6:55 [PATCH] ASoC: renesas: rz-ssi: Clean up on error in probe() Dan Carpenter
2025-01-17 11:51 ` Claudiu Beznea
2025-01-20 10:32   ` Dan Carpenter

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®