* [PATCH] ASoC: fsl: Add missing error handling in pcm030_fabric_probe
@ 2022-01-26 11:33 Miaoqian Lin
2022-01-26 12:58 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Miaoqian Lin @ 2022-01-26 11:33 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Miaoqian Lin, Eric Millbrandt, alsa-devel, linux-kernel
Add the missing platform_device_put() and platform_device_del()
before return from pcm030_fabric_probe in the error handling case.
Fixes: c912fa913446 ("ASoC: fsl: register the wm9712-codec")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
sound/soc/fsl/pcm030-audio-fabric.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index af3c3b90c0ac..02c4ae20c673 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -93,15 +93,22 @@ static int pcm030_fabric_probe(struct platform_device *op)
dev_err(&op->dev, "platform_device_alloc() failed\n");
ret = platform_device_add(pdata->codec_device);
- if (ret)
+ if (ret) {
dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
+ goto exit_device_put;
+ }
ret = snd_soc_register_card(card);
if (ret)
dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
platform_set_drvdata(op, pdata);
+ return ret;
+exit_release_dev:
+ platform_device_del(pdata->codec_device);
+exit_device_put:
+ platform_device_put(pdata->codec_device);
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: fsl: Add missing error handling in pcm030_fabric_probe
2022-01-26 11:33 [PATCH] ASoC: fsl: Add missing error handling in pcm030_fabric_probe Miaoqian Lin
@ 2022-01-26 12:58 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-01-26 12:58 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Eric Millbrandt,
alsa-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
On Wed, Jan 26, 2022 at 11:33:04AM +0000, Miaoqian Lin wrote:
> Add the missing platform_device_put() and platform_device_del()
> before return from pcm030_fabric_probe in the error handling case.
> ret = platform_device_add(pdata->codec_device);
> - if (ret)
> + if (ret) {
> dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
> + goto exit_device_put;
> + }
>
> ret = snd_soc_register_card(card);
> if (ret)
> dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
>
> platform_set_drvdata(op, pdata);
> + return ret;
This means we'll skip the cleanup of the platform device that you just
added if card creation fails:
> +exit_release_dev:
> + platform_device_del(pdata->codec_device);
> +exit_device_put:
> + platform_device_put(pdata->codec_device);
> return ret;
It needs to return early only if the card registration failed.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: fsl: Add missing error handling in pcm030_fabric_probe
@ 2022-01-26 12:58 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-01-26 12:58 UTC (permalink / raw)
To: Miaoqian Lin
Cc: alsa-devel, linux-kernel, Takashi Iwai, Liam Girdwood, Eric Millbrandt
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
On Wed, Jan 26, 2022 at 11:33:04AM +0000, Miaoqian Lin wrote:
> Add the missing platform_device_put() and platform_device_del()
> before return from pcm030_fabric_probe in the error handling case.
> ret = platform_device_add(pdata->codec_device);
> - if (ret)
> + if (ret) {
> dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
> + goto exit_device_put;
> + }
>
> ret = snd_soc_register_card(card);
> if (ret)
> dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
>
> platform_set_drvdata(op, pdata);
> + return ret;
This means we'll skip the cleanup of the platform device that you just
added if card creation fails:
> +exit_release_dev:
> + platform_device_del(pdata->codec_device);
> +exit_device_put:
> + platform_device_put(pdata->codec_device);
> return ret;
It needs to return early only if the card registration failed.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] ASoC: fsl: Add missing error handling in pcm030_fabric_probe
2022-01-26 12:58 ` Mark Brown
(?)
@ 2022-01-27 13:13 ` Miaoqian Lin
2022-01-28 15:58 ` Mark Brown
-1 siblings, 1 reply; 5+ messages in thread
From: Miaoqian Lin @ 2022-01-27 13:13 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Eric Millbrandt, alsa-devel, linux-kernel
Cc: linmq006
Add the missing platform_device_put() and platform_device_del()
before return from pcm030_fabric_probe in the error handling case.
Fixes: c912fa913446 ("ASoC: fsl: register the wm9712-codec")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
Changes in v2:
- avoid return early before the card registration.
---
sound/soc/fsl/pcm030-audio-fabric.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index af3c3b90c0ac..83b4a22bf15a 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -93,16 +93,21 @@ static int pcm030_fabric_probe(struct platform_device *op)
dev_err(&op->dev, "platform_device_alloc() failed\n");
ret = platform_device_add(pdata->codec_device);
- if (ret)
+ if (ret) {
dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
+ platform_device_put(pdata->codec_device);
+ }
ret = snd_soc_register_card(card);
- if (ret)
+ if (ret) {
dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
+ platform_device_del(pdata->codec_device);
+ platform_device_put(pdata->codec_device);
+ }
platform_set_drvdata(op, pdata);
-
return ret;
+
}
static int pcm030_fabric_remove(struct platform_device *op)
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ASoC: fsl: Add missing error handling in pcm030_fabric_probe
2022-01-27 13:13 ` [PATCH v2] " Miaoqian Lin
@ 2022-01-28 15:58 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-01-28 15:58 UTC (permalink / raw)
To: linux-kernel, Eric Millbrandt, Miaoqian Lin, alsa-devel,
Jaroslav Kysela, Liam Girdwood, Takashi Iwai
On Thu, 27 Jan 2022 13:13:34 +0000, Miaoqian Lin wrote:
> Add the missing platform_device_put() and platform_device_del()
> before return from pcm030_fabric_probe in the error handling case.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus
Thanks!
[1/1] ASoC: fsl: Add missing error handling in pcm030_fabric_probe
commit: fb25621da5702c104ce0a48de5b174ced09e5b4e
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] 5+ messages in thread
end of thread, other threads:[~2022-01-28 15:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 11:33 [PATCH] ASoC: fsl: Add missing error handling in pcm030_fabric_probe Miaoqian Lin
2022-01-26 12:58 ` Mark Brown
2022-01-26 12:58 ` Mark Brown
2022-01-27 13:13 ` [PATCH v2] " Miaoqian Lin
2022-01-28 15:58 ` 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.