ASoC: fsl: Add missing error handling in pcm030_fabric_probe
PATCH 1/1 ASoC: fsl: Add missing error handling in pcm030_fabric_probe
Add the missing platform_device_put() and platform_device_del() before return from pcm030_fabric_probe in the error handling case.
--- sound/soc/fsl/pcm030-audio-fabric.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/fsl/pcm030-audio-fabric.c +8 -1
@@ -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; }
Signature · 1 line
2.17.1
Mark Brown
maintainerQuoted 6 lines · Miaoqian Lin
Add the missing
platform_device_put()andplatform_device_del()before return frompcm030_fabric_probein the error handling case.sound/soc/fsl/pcm030-audio-fabric.c +1
-1ret =platform_device_add (pdata->codec_device); -if (ret) +if (ret) {
sound/soc/fsl/pcm030-audio-fabric.c static int pcm030_fabric_probe(struct platform_device *op) · line 106
Quoted 10 lines
sound/soc/fsl/pcm030-audio-fabric.c +3
-0dev_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:
sound/soc/fsl/pcm030-audio-fabric.c static int pcm030_fabric_probe(struct platform_device *op) · line 112
Quoted 5 lines
sound/soc/fsl/pcm030-audio-fabric.c +4
-0+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.
PATCH v2 1/1 ASoC: fsl: Add missing error handling in pcm030_fabric_probe
Add the missing platform_device_put() and platform_device_del() before return from pcm030_fabric_probe in the error handling case.
---
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(-)
sound/soc/fsl/pcm030-audio-fabric.c +8 -3
@@ -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)
Signature · 1 line
2.17.1
Mark Brown
maintainerQuoted 4 lines · Miaoqian Lin
Add the missing
platform_device_put()andplatform_device_del()before return frompcm030_fabric_probein 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