All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
@ 2022-05-11  6:58 ` Miaoqian Lin
  0 siblings, 0 replies; 8+ messages in thread
From: Miaoqian Lin @ 2022-05-11  6:58 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, NXP Linux Team,
	Richard Zhao, alsa-devel, linuxppc-dev, linux-arm-kernel,
	linux-kernel
  Cc: linmq006

of_find_i2c_device_by_node() takes a reference,
In error paths, we should call put_device() to drop
the reference to aviod refount leak.

Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 sound/soc/fsl/imx-sgtl5000.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 8daced42d55e..580a0d963f0e 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -120,19 +120,19 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		ret = -ENOMEM;
-		goto fail;
+		goto put_device;
 	}
 
 	comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL);
 	if (!comp) {
 		ret = -ENOMEM;
-		goto fail;
+		goto put_device;
 	}
 
 	data->codec_clk = clk_get(&codec_dev->dev, NULL);
 	if (IS_ERR(data->codec_clk)) {
 		ret = PTR_ERR(data->codec_clk);
-		goto fail;
+		goto put_device;
 	}
 
 	data->clk_frequency = clk_get_rate(data->codec_clk);
@@ -158,10 +158,10 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 	data->card.dev = &pdev->dev;
 	ret = snd_soc_of_parse_card_name(&data->card, "model");
 	if (ret)
-		goto fail;
+		goto put_device;
 	ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
 	if (ret)
-		goto fail;
+		goto put_device;
 	data->card.num_links = 1;
 	data->card.owner = THIS_MODULE;
 	data->card.dai_link = &data->dai;
@@ -174,7 +174,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 	ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
 	if (ret) {
 		dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n");
-		goto fail;
+		goto put_device;
 	}
 
 	of_node_put(ssi_np);
@@ -182,6 +182,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 
 	return 0;
 
+put_device:
+	put_device(&codec_dev->dev);
 fail:
 	if (data && !IS_ERR(data->codec_clk))
 		clk_put(data->codec_clk);
-- 
2.25.1


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

* [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
@ 2022-05-11  6:58 ` Miaoqian Lin
  0 siblings, 0 replies; 8+ messages in thread
From: Miaoqian Lin @ 2022-05-11  6:58 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, NXP Linux Team,
	Richard Zhao, alsa-devel, linuxppc-dev, linux-arm-kernel,
	linux-kernel
  Cc: linmq006

of_find_i2c_device_by_node() takes a reference,
In error paths, we should call put_device() to drop
the reference to aviod refount leak.

Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 sound/soc/fsl/imx-sgtl5000.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 8daced42d55e..580a0d963f0e 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -120,19 +120,19 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		ret = -ENOMEM;
-		goto fail;
+		goto put_device;
 	}
 
 	comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL);
 	if (!comp) {
 		ret = -ENOMEM;
-		goto fail;
+		goto put_device;
 	}
 
 	data->codec_clk = clk_get(&codec_dev->dev, NULL);
 	if (IS_ERR(data->codec_clk)) {
 		ret = PTR_ERR(data->codec_clk);
-		goto fail;
+		goto put_device;
 	}
 
 	data->clk_frequency = clk_get_rate(data->codec_clk);
@@ -158,10 +158,10 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 	data->card.dev = &pdev->dev;
 	ret = snd_soc_of_parse_card_name(&data->card, "model");
 	if (ret)
-		goto fail;
+		goto put_device;
 	ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
 	if (ret)
-		goto fail;
+		goto put_device;
 	data->card.num_links = 1;
 	data->card.owner = THIS_MODULE;
 	data->card.dai_link = &data->dai;
@@ -174,7 +174,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 	ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
 	if (ret) {
 		dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n");
-		goto fail;
+		goto put_device;
 	}
 
 	of_node_put(ssi_np);
@@ -182,6 +182,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 
 	return 0;
 
+put_device:
+	put_device(&codec_dev->dev);
 fail:
 	if (data && !IS_ERR(data->codec_clk))
 		clk_put(data->codec_clk);
-- 
2.25.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] 8+ messages in thread

* Re: [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
  2022-05-11  6:58 ` Miaoqian Lin
  (?)
  (?)
@ 2022-05-11 10:32   ` Fabio Estevam
  -1 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2022-05-11 10:32 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Shengjiu Wang, Xiubo Li, Nicolin Chen, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, Richard Zhao,
	Linux-ALSA, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-kernel

On Wed, May 11, 2022 at 3:58 AM Miaoqian Lin <linmq006@gmail.com> wrote:
>
> of_find_i2c_device_by_node() takes a reference,
> In error paths, we should call put_device() to drop
> the reference to aviod refount leak.

s/aviod refount/avoid refcount

> Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

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

* Re: [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
@ 2022-05-11 10:32   ` Fabio Estevam
  0 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2022-05-11 10:32 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Linux-ALSA, linuxppc-dev, linux-kernel, Xiubo Li, Shawn Guo,
	Sascha Hauer, Takashi Iwai, Liam Girdwood, Jaroslav Kysela,
	Nicolin Chen, Mark Brown, NXP Linux Team,
	Pengutronix Kernel Team, Shengjiu Wang, Richard Zhao,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Wed, May 11, 2022 at 3:58 AM Miaoqian Lin <linmq006@gmail.com> wrote:
>
> of_find_i2c_device_by_node() takes a reference,
> In error paths, we should call put_device() to drop
> the reference to aviod refount leak.

s/aviod refount/avoid refcount

> Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

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

* Re: [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
@ 2022-05-11 10:32   ` Fabio Estevam
  0 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2022-05-11 10:32 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Shengjiu Wang, Xiubo Li, Nicolin Chen, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, NXP Linux Team, Richard Zhao,
	Linux-ALSA, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-kernel

On Wed, May 11, 2022 at 3:58 AM Miaoqian Lin <linmq006@gmail.com> wrote:
>
> of_find_i2c_device_by_node() takes a reference,
> In error paths, we should call put_device() to drop
> the reference to aviod refount leak.

s/aviod refount/avoid refcount

> Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

_______________________________________________
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] 8+ messages in thread

* Re: [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
@ 2022-05-11 10:32   ` Fabio Estevam
  0 siblings, 0 replies; 8+ messages in thread
From: Fabio Estevam @ 2022-05-11 10:32 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Linux-ALSA, linuxppc-dev, linux-kernel, Xiubo Li, Shawn Guo,
	Sascha Hauer, Takashi Iwai, Liam Girdwood, Nicolin Chen,
	Mark Brown, NXP Linux Team, Pengutronix Kernel Team,
	Shengjiu Wang, Richard Zhao,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Wed, May 11, 2022 at 3:58 AM Miaoqian Lin <linmq006@gmail.com> wrote:
>
> of_find_i2c_device_by_node() takes a reference,
> In error paths, we should call put_device() to drop
> the reference to aviod refount leak.

s/aviod refount/avoid refcount

> Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

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

* Re: [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
  2022-05-11  6:58 ` Miaoqian Lin
@ 2022-05-12 14:12   ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-05-12 14:12 UTC (permalink / raw)
  To: Fabio Estevam, alsa-devel, Takashi Iwai, linuxppc-dev, shawnguo,
	Jaroslav Kysela, linux-arm-kernel, Shengjiu Wang, kernel,
	Nicolin Chen, linux-kernel, Liam Girdwood, linux-imx, linmq006,
	richard.zhao, Xiubo Li, Sascha Hauer

On Wed, 11 May 2022 10:58:03 +0400, Miaoqian Lin wrote:
> of_find_i2c_device_by_node() takes a reference,
> In error paths, we should call put_device() to drop
> the reference to aviod refount leak.
> 
> 

Applied to

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

Thanks!

[1/1] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
      commit: 41cd312dfe980af869c3503b4d38e62ed20dd3b7

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

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

* Re: [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
@ 2022-05-12 14:12   ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-05-12 14:12 UTC (permalink / raw)
  To: Fabio Estevam, alsa-devel, Takashi Iwai, linuxppc-dev, shawnguo,
	Jaroslav Kysela, linux-arm-kernel, Shengjiu Wang, kernel,
	Nicolin Chen, linux-kernel, Liam Girdwood, linux-imx, linmq006,
	richard.zhao, Xiubo Li, Sascha Hauer

On Wed, 11 May 2022 10:58:03 +0400, Miaoqian Lin wrote:
> of_find_i2c_device_by_node() takes a reference,
> In error paths, we should call put_device() to drop
> the reference to aviod refount leak.
> 
> 

Applied to

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

Thanks!

[1/1] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
      commit: 41cd312dfe980af869c3503b4d38e62ed20dd3b7

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] 8+ messages in thread

end of thread, other threads:[~2022-05-12 14:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  6:58 [PATCH] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe Miaoqian Lin
2022-05-11  6:58 ` Miaoqian Lin
2022-05-11 10:32 ` Fabio Estevam
2022-05-11 10:32   ` Fabio Estevam
2022-05-11 10:32   ` Fabio Estevam
2022-05-11 10:32   ` Fabio Estevam
2022-05-12 14:12 ` Mark Brown
2022-05-12 14:12   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.