All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lu Guanqun <guanqun.lu@intel.com>
To: ALSA <alsa-devel@alsa-project.org>
Cc: Koul Vinod <vinod.koul@intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 4/4] ASoC: sst_platform: fix memory leak
Date: Tue, 06 Sep 2011 15:21:43 +0800	[thread overview]
Message-ID: <20110906072142.7310.25845.stgit@localhost> (raw)
In-Reply-To: <20110906072129.7310.6960.stgit@localhost>

snd_pcm_hw_constraint_integer() could return -1, in this case, sst platform is
not opened successfully.  However the corresponding close callback isn't able
to be called later on to release these two allocated memories, thus resulting
in memory leak.

This patch moves the check for hardware contraints earlier, thus resolving this
issue.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Cc: Vinod Koul <vinod.koul@intel.com>
---
 sound/soc/mid-x86/sst_platform.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/mid-x86/sst_platform.c
index af666ae..9925d20 100644
--- a/sound/soc/mid-x86/sst_platform.c
+++ b/sound/soc/mid-x86/sst_platform.c
@@ -233,6 +233,10 @@ static int sst_platform_open(struct snd_pcm_substream *substream)
 	pr_debug("sst_platform_open called\n");
 
 	snd_soc_set_runtime_hwparams(substream, &sst_platform_pcm_hw);
+	ret_val = snd_pcm_hw_constraint_integer(runtime,
+						SNDRV_PCM_HW_PARAM_PERIODS);
+	if (ret_val < 0)
+		return ret_val;
 
 	stream = kzalloc(sizeof(*stream), GFP_KERNEL);
 	if (!stream)
@@ -260,8 +264,8 @@ static int sst_platform_open(struct snd_pcm_substream *substream)
 		return ret_val;
 	}
 	runtime->private_data = stream;
-	return snd_pcm_hw_constraint_integer(runtime,
-			 SNDRV_PCM_HW_PARAM_PERIODS);
+
+	return 0;
 }
 
 static int sst_platform_close(struct snd_pcm_substream *substream)

  parent reply	other threads:[~2011-09-06  7:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06  7:21 [PATCH 1/4] intel_sst: fix comment typo Lu Guanqun
2011-09-06  7:21 ` [PATCH 2/4] ASoC: sst_platform: trivial coding style fix Lu Guanqun
2011-09-06  7:21 ` [PATCH 3/4] ASoC: sst_platform: using builtin function Lu Guanqun
2011-09-06  7:21 ` Lu Guanqun [this message]
2011-09-07  0:39 ` [PATCH 1/4] intel_sst: fix comment typo Koul, Vinod
2011-09-07  0:52   ` Lu Guanqun
2011-09-08 21:17     ` Girdwood, Liam
2011-09-08 22:43 ` 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=20110906072142.7310.25845.stgit@localhost \
    --to=guanqun.lu@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=vinod.koul@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.