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: Barry Song <21cnbao@gmail.com>,
	Kuninori Morimoto <morimoto.kuninori@renesas.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Mike Arthur <linux@wolfsonmicro.com>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Liam Girdwood <lrg@slimlogic.co.uk>
Subject: [PATCH v2 06/12] wm8904: fix resource reclaim in wm8904_register error path
Date: Fri, 23 Jul 2010 05:53:48 +0000	[thread overview]
Message-ID: <1279864434-8010-7-git-send-email-axel.lin@gmail.com> (raw)
In-Reply-To: <1279864434-8010-1-git-send-email-axel.lin@gmail.com>

This patch includes below fixes:
1. wm8904 need to be kfreed in wm8904_register() error path before return.
2. fix the error path for snd_soc_register_codec() fail and
   snd_soc_register_dai() fail to properly free resources.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 sound/soc/codecs/wm8904.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 87f14f8..f7dcabf 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -2433,7 +2433,8 @@ static int wm8904_register(struct wm8904_priv *wm8904,
 
 	if (wm8904_codec) {
 		dev_err(codec->dev, "Another WM8904 is registered\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err;
 	}
 
 	mutex_init(&codec->mutex);
@@ -2462,7 +2463,8 @@ static int wm8904_register(struct wm8904_priv *wm8904,
 	default:
 		dev_err(codec->dev, "Unknown device type %d\n",
 			wm8904->devtype);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err;
 	}
 
 	memcpy(codec->reg_cache, wm8904_reg, sizeof(wm8904_reg));
@@ -2566,18 +2568,19 @@ static int wm8904_register(struct wm8904_priv *wm8904,
 	ret = snd_soc_register_codec(codec);
 	if (ret != 0) {
 		dev_err(codec->dev, "Failed to register codec: %d\n", ret);
-		return ret;
+		goto err_enable;
 	}
 
 	ret = snd_soc_register_dai(&wm8904_dai);
 	if (ret != 0) {
 		dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
-		snd_soc_unregister_codec(codec);
-		return ret;
+		goto err_codec;
 	}
 
 	return 0;
 
+err_codec:
+	snd_soc_unregister_codec(codec);
 err_enable:
 	regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
 err_get:
-- 
1.7.0.4


  parent reply	other threads:[~2010-07-23  5:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-23  5:53 [PATCH v2 00/12] sound/alsa/soc/codec: fix memory leak and resource relaim in error path Axel Lin
2010-07-23  5:53 ` [PATCH v2 01/12] ad1836: fix a memory leak if another ad1836 is registered Axel Lin
2010-07-23  5:53 ` [PATCH v2 02/12] ak4642: fix a memory leak if failed to initialise AK4642 Axel Lin
2010-07-23  5:53 ` [PATCH v2 03/12] da7210: fix a memory leak if failed to initialise da7210 audio codec Axel Lin
2010-07-23  5:53 ` [PATCH v2 04/12] wm8523: fix resource reclaim in wm8523_register error path Axel Lin
2010-07-23  5:53 ` [PATCH v2 05/12] wm8711: fix a memory leak if another WM8711 is registered Axel Lin
2010-07-23  5:53 ` Axel Lin [this message]
2010-07-23  5:53 ` [PATCH v2 07/12] wm8940: fix a memory leak if wm8940_register return error Axel Lin
2010-07-23  5:53 ` [PATCH v2 08/12] wm8955: fix resource reclaim in wm8955_register error path Axel Lin
2010-07-23  5:53 ` [PATCH v2 09/12] wm8961: fix resource reclaim in wm8961_register " Axel Lin
2010-07-23  5:53 ` [PATCH v2 10/12] wm8974: fix a memory leak if another WM8974 is registered Axel Lin
2010-07-23  5:53 ` [PATCH v2 11/12] wm8978: fix a memory leak if a wm8978_register fail Axel Lin
2010-07-23  5:53 ` [PATCH v2 12/12] wm9081: fix resource reclaim in wm9081_register error path Axel Lin
2010-07-23 18:21 ` [PATCH v2 00/12] sound/alsa/soc/codec: fix memory leak and resource relaim in " Liam Girdwood

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=1279864434-8010-7-git-send-email-axel.lin@gmail.com \
    --to=axel.lin@gmail.com \
    --cc=21cnbao@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@wolfsonmicro.com \
    --cc=lrg@slimlogic.co.uk \
    --cc=morimoto.kuninori@renesas.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