linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe
@ 2022-03-16 11:15 Miaoqian Lin
  2022-03-16 12:09 ` Codrin.Ciubotariu
  2022-03-16 20:35 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-03-16 11:15 UTC (permalink / raw)
  To: Codrin Ciubotariu, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Richard Genoud, alsa-devel, linux-arm-kernel, linux-kernel
  Cc: linmq006

The device_node pointer is returned by of_parse_phandle()  with refcount
incremented. We should use of_node_put() on it when done.

This function only calls of_node_put() in the regular path.
And it will cause refcount leak in error path.

Fixes: fdbcb3cba54b ("ASoC: atmel: machine driver for at91sam9x5-wm8731 boards")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 sound/soc/atmel/sam9x5_wm8731.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c
index 7c45dc4f8c1b..99310e40e7a6 100644
--- a/sound/soc/atmel/sam9x5_wm8731.c
+++ b/sound/soc/atmel/sam9x5_wm8731.c
@@ -142,7 +142,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
 	if (!cpu_np) {
 		dev_err(&pdev->dev, "atmel,ssc-controller node missing\n");
 		ret = -EINVAL;
-		goto out;
+		goto out_put_codec_np;
 	}
 	dai->cpus->of_node = cpu_np;
 	dai->platforms->of_node = cpu_np;
@@ -153,12 +153,9 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Failed to set SSC %d for audio: %d\n",
 			ret, priv->ssc_id);
-		goto out;
+		goto out_put_cpu_np;
 	}
 
-	of_node_put(codec_np);
-	of_node_put(cpu_np);
-
 	ret = devm_snd_soc_register_card(&pdev->dev, card);
 	if (ret) {
 		dev_err(&pdev->dev, "Platform device allocation failed\n");
@@ -167,10 +164,14 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "%s ok\n", __func__);
 
-	return ret;
+	goto out_put_cpu_np;
 
 out_put_audio:
 	atmel_ssc_put_audio(priv->ssc_id);
+out_put_cpu_np:
+	of_node_put(cpu_np);
+out_put_codec_np:
+	of_node_put(codec_np);
 out:
 	return ret;
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe
  2022-03-16 11:15 [PATCH] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe Miaoqian Lin
@ 2022-03-16 12:09 ` Codrin.Ciubotariu
  2022-03-16 20:35 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Codrin.Ciubotariu @ 2022-03-16 12:09 UTC (permalink / raw)
  To: linmq006, lgirdwood, broonie, perex, tiwai, Nicolas.Ferre,
	alexandre.belloni, Claudiu.Beznea, richard.genoud, alsa-devel,
	linux-arm-kernel, linux-kernel

On 16.03.2022 13:15, Miaoqian Lin wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> The device_node pointer is returned by of_parse_phandle()  with refcount
> incremented. We should use of_node_put() on it when done.
> 
> This function only calls of_node_put() in the regular path.
> And it will cause refcount leak in error path.
> 
> Fixes: fdbcb3cba54b ("ASoC: atmel: machine driver for at91sam9x5-wm8731 boards")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>

Thanks!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe
  2022-03-16 11:15 [PATCH] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe Miaoqian Lin
  2022-03-16 12:09 ` Codrin.Ciubotariu
@ 2022-03-16 20:35 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-03-16 20:35 UTC (permalink / raw)
  To: Claudiu Beznea, Codrin Ciubotariu, alsa-devel, Jaroslav Kysela,
	Miaoqian Lin, Alexandre Belloni, Richard Genoud, linux-kernel,
	linux-arm-kernel, Liam Girdwood, Nicolas Ferre, Takashi Iwai

On Wed, 16 Mar 2022 11:15:30 +0000, Miaoqian Lin wrote:
> The device_node pointer is returned by of_parse_phandle()  with refcount
> incremented. We should use of_node_put() on it when done.
> 
> This function only calls of_node_put() in the regular path.
> And it will cause refcount leak in error path.
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe
      commit: 740dc3e846537c3743da98bf106f376023fd085c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-03-16 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 11:15 [PATCH] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe Miaoqian Lin
2022-03-16 12:09 ` Codrin.Ciubotariu
2022-03-16 20:35 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).