diff mbox series

ASoC: fsl: Fix error handling in pcm030_fabric_probe

Message ID 20220301075351.31691-1-linmq006@gmail.com (mailing list archive)
State New, archived
Headers show
Series ASoC: fsl: Fix error handling in pcm030_fabric_probe | expand

Commit Message

Miaoqian Lin March 1, 2022, 7:53 a.m. UTC
This will call twice platform_device_put()
if both platform_device_add() and snd_soc_register_card() fails.
Fix it by using goto label to avoid duplicating the error code logic.

Fixes: fb25621da570 ("ASoC: fsl: Add missing error handling in pcm030_fabric_probe")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 sound/soc/fsl/pcm030-audio-fabric.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Mark Brown March 2, 2022, 1:44 p.m. UTC | #1
On Tue, Mar 01, 2022 at 07:53:48AM +0000, Miaoqian Lin wrote:
> This will call twice platform_device_put()
> if both platform_device_add() and snd_soc_register_card() fails.
> Fix it by using goto label to avoid duplicating the error code logic.

This doesn't apply against current code, please check and resend.
diff mbox series

Patch

diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index 83b4a22bf15a..d397bb97f37b 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -95,19 +95,23 @@  static int pcm030_fabric_probe(struct platform_device *op)
 	ret = platform_device_add(pdata->codec_device);
 	if (ret) {
 		dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
-		platform_device_put(pdata->codec_device);
+		goto err_add;
 	}
 
 	ret = snd_soc_register_card(card);
 	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);
+		goto err_register;
 	}
 
 	platform_set_drvdata(op, pdata);
 	return ret;
 
+err_register:
+	platform_device_del(pdata->codec_device);
+err_add:
+	platform_device_put(pdata->codec_device);
+	return ret;
 }
 
 static int pcm030_fabric_remove(struct platform_device *op)