public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai
@ 2011-04-06 15:25 Lu Guanqun
  2011-04-06 15:25 ` [PATCH 2/2] ASoC: fix config error path Lu Guanqun
  2011-04-06 23:25 ` [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Lu Guanqun @ 2011-04-06 15:25 UTC (permalink / raw)
  To: ALSA; +Cc: Takashi Iwai, Mark Brown, Liam Girdwood

Suppose we have:

	cpu_dai
		channels_min = 1
		channels_max = 1

	codec_dai
		channels_min = 2
		channels_max = 2

This is a mismatch that should not happen, however according to the current
code, the result of runtime->hw will be:

		channels_min = 2
		channels_max = 1

We better spot it early. This patch checks this mismatch.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
---
 sound/soc/soc-core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0cf6997..88bb206 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -640,7 +640,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 			codec_dai->name, cpu_dai->name);
 		goto config_err;
 	}
-	if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
+	if (!runtime->hw.channels_min || !runtime->hw.channels_max ||
+	    runtime->hw.channels_min > runtime->hw.channels_max) {
 		printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
 				codec_dai->name, cpu_dai->name);
 		goto config_err;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ASoC: fix config error path
  2011-04-06 15:25 [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai Lu Guanqun
@ 2011-04-06 15:25 ` Lu Guanqun
  2011-04-06 23:25 ` [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Lu Guanqun @ 2011-04-06 15:25 UTC (permalink / raw)
  To: ALSA; +Cc: Takashi Iwai, Mark Brown, Liam Girdwood

initialize ret to invalid value so that when we reach the config error path in
soc_pcm_open, it will return the correct error code. without this patch, though
config error path is executed, soc_pcm_open will return 0 in
snd_pcm_open_substream and then cause double release of substream.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
---
 sound/soc/soc-core.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 88bb206..b8e69f2 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -629,6 +629,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 			runtime->hw.rates |= codec_dai_drv->capture.rates;
 	}
 
+	ret = -EINVAL;
 	snd_pcm_limit_hw_rates(runtime);
 	if (!runtime->hw.rates) {
 		printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai
  2011-04-06 15:25 [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai Lu Guanqun
  2011-04-06 15:25 ` [PATCH 2/2] ASoC: fix config error path Lu Guanqun
@ 2011-04-06 23:25 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-04-06 23:25 UTC (permalink / raw)
  To: Lu Guanqun; +Cc: Takashi Iwai, ALSA, Liam Girdwood

On Wed, Apr 06, 2011 at 11:25:11PM +0800, Lu Guanqun wrote:
> Suppose we have:
> 
> 	cpu_dai
> 		channels_min = 1
> 		channels_max = 1

Applied both, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-06 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06 15:25 [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai Lu Guanqun
2011-04-06 15:25 ` [PATCH 2/2] ASoC: fix config error path Lu Guanqun
2011-04-06 23:25 ` [PATCH 1/2] ASoC: check channel mismatch between cpu_dai and codec_dai Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox