mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>, Miaoqian Lin <linmq006@gmail.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] ASoC: fsl: Fix error handling in pcm030_fabric_probe
Date: Wed, 20 Apr 2022 02:18:52 +0000	[thread overview]
Message-ID: <20220420021855.8224-1-linmq006@gmail.com> (raw)
In-Reply-To: <Yh90u+E3RTuGEDWU@sirena.org.uk>

This will call twice platform_device_put()
if both platform_device_add() and snd_soc_register_card() fails.
return early on error  to avoid duplicating the error code logic.

Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
changes in v2:
- use return statement to return early when fails
- rebase on top of commit 559089e0a93d ("vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP")
---
 sound/soc/fsl/pcm030-audio-fabric.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index 83b4a22bf15a..096a37993ad3 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -89,13 +89,16 @@ static int pcm030_fabric_probe(struct platform_device *op)
 		dev_err(&op->dev, "request_module returned: %d\n", ret);
 
 	pdata->codec_device = platform_device_alloc("wm9712-codec", -1);
-	if (!pdata->codec_device)
+	if (!pdata->codec_device) {
 		dev_err(&op->dev, "platform_device_alloc() failed\n");
+		return -ENOMEM;
+	}
 
 	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);
+		return ret;
 	}
 
 	ret = snd_soc_register_card(card);
@@ -103,6 +106,7 @@ static int pcm030_fabric_probe(struct platform_device *op)
 		dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
 		platform_device_del(pdata->codec_device);
 		platform_device_put(pdata->codec_device);
+		return ret;
 	}
 
 	platform_set_drvdata(op, pdata);
-- 
2.17.1


  reply	other threads:[~2022-04-20  2:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  7:53 [PATCH] " Miaoqian Lin
2022-03-02 13:44 ` Mark Brown
2022-04-20  2:18   ` Miaoqian Lin [this message]
2022-04-20 13:00     ` [PATCH v2] " Mark Brown
2022-04-20 13:35       ` Miaoqian Lin
2022-04-20 13:41         ` Mark Brown
2022-04-20 13:45           ` Miaoqian Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420021855.8224-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome