public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Graeme Gregory <graeme@openmoko.org>,
	Jassi Brar <jassi.brar@samsung.com>,
	Liam Girdwood <lrg@slimlogic.co.uk>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	alsa-devel@alsa-project.org
Subject: [PATCH 2/4] ASoC: Fix resource leask in neo1973_gta02_init() error path
Date: Fri, 26 Nov 2010 14:52:47 +0800	[thread overview]
Message-ID: <1290754367.25125.4.camel@mola> (raw)
In-Reply-To: <1290754245.25125.1.camel@mola>

Properly free allocated resources in neo1973_gta02_init() error path.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 sound/soc/samsung/neo1973_gta02_wm8753.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/sound/soc/samsung/neo1973_gta02_wm8753.c b/sound/soc/samsung/neo1973_gta02_wm8753.c
index 8c65b63..3eec610 100644
--- a/sound/soc/samsung/neo1973_gta02_wm8753.c
+++ b/sound/soc/samsung/neo1973_gta02_wm8753.c
@@ -439,24 +439,20 @@ static int __init neo1973_gta02_init(void)
 
 	/* register bluetooth DAI here */
 	ret = snd_soc_register_dai(&neo1973_gta02_snd_device->dev, &bt_dai);
-	if (ret) {
-		platform_device_put(neo1973_gta02_snd_device);
-		return ret;
-	}
+	if (ret)
+		goto err_put_device;
 
 	platform_set_drvdata(neo1973_gta02_snd_device, &neo1973_gta02);
 	ret = platform_device_add(neo1973_gta02_snd_device);
 
-	if (ret) {
-		platform_device_put(neo1973_gta02_snd_device);
-		return ret;
-	}
+	if (ret)
+		goto err_unregister_dai;
 
 	/* Initialise GPIOs used by amp */
 	ret = gpio_request(GTA02_GPIO_HP_IN, "GTA02_HP_IN");
 	if (ret) {
 		pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_HP_IN);
-		goto err_unregister_device;
+		goto err_del_device;
 	}
 
 	ret = gpio_direction_output(GTA02_GPIO_HP_IN, 1);
@@ -483,8 +479,12 @@ err_free_gpio_amp_shut:
 	gpio_free(GTA02_GPIO_AMP_SHUT);
 err_free_gpio_hp_in:
 	gpio_free(GTA02_GPIO_HP_IN);
-err_unregister_device:
-	platform_device_unregister(neo1973_gta02_snd_device);
+err_del_device:
+	platform_device_del(neo1973_gta02_snd_device);
+err_unregister_dai:
+	snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev);
+err_put_device:
+	platform_device_put(neo1973_gta02_snd_device);
 	return ret;
 }
 module_init(neo1973_gta02_init);
-- 
1.7.2




  parent reply	other threads:[~2010-11-26  6:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-26  6:50 [PATCH 0/4] Fixes resource leaks for Samsung SoCs Axel Lin
2010-11-26  6:51 ` [PATCH 1/4] ASoC: Fix resource leask in goni_wm8994.c Axel Lin
2010-11-29  0:24   ` Thiago Farina
2010-11-26  6:52 ` Axel Lin [this message]
2010-11-26  6:53 ` [PATCH 3/4] ASoC: Add missing gpio_free(S3C64XX_GPK(12)) in smartq_exit() Axel Lin
2010-11-26  6:54 ` [PATCH 4/4] ASoC: Fix resource leask in smdk_spdif.c Axel Lin
2010-11-26 12:26 ` [PATCH 0/4] Fixes resource leaks for Samsung SoCs Liam Girdwood
2010-11-28 11:02   ` Mark Brown
2010-11-28 23:40 ` [alsa-devel] " Jassi Brar
2010-11-29 11:01   ` Mark Brown

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=1290754367.25125.4.camel@mola \
    --to=axel.lin@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=graeme@openmoko.org \
    --cc=jassi.brar@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    /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