[alsa-devel] [ASoC] bug in soc_pcm_open
Hi,
it seems there is a bug in soc_pcm_open. In some case [1] we are in a error path, but we don't set the ret return value.
This cause bug/crash from alsa core.
Thanks
Matthieu
[1]http://hg-mirror.alsa-project.org/alsa-kernel/file/38926de0e79c/soc/soc-core... if (!runtime->hw.rates) {
218 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
219 codec_dai->name, cpu_dai->name);
220 goto machine_err;
221 }
222 if (!runtime->hw.formats) {
223 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
224 codec_dai->name, cpu_dai->name);
225 goto machine_err;
226 }
227 if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
228 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
229 codec_dai->name, cpu_dai->name);
230 goto machine_err;
231 }
Seems like a problem, Adding to that
if (machine->ops && machine->ops->shutdown) machine->ops->shutdown(substream);
if (platform->pcm_ops->close) platform->pcm_ops->close(substream);
if (cpu_dai->ops.shutdown) cpu_dai->ops.shutdown(substream);
if it is a error condition then above functions are called twice (also in snd_codec_close())
Nobin Mathew
On 6/11/07, Matthieu CASTET matthieu.castet@parrot.com wrote:
Hi,
it seems there is a bug in soc_pcm_open. In some case [1] we are in a error path, but we don't set the ret return value.
This cause bug/crash from alsa core.
Thanks
Matthieu
[1]http://hg-mirror.alsa-project.org/alsa-kernel/file/38926de0e79c/soc/soc-core... if (!runtime->hw.rates) {
218 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", 219 codec_dai->name, cpu_dai->name); 220 goto machine_err; 221 } 222 if (!runtime->hw.formats) { 223 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", 224 codec_dai->name, cpu_dai->name); 225 goto machine_err; 226 } 227 if (!runtime->hw.channels_min || !runtime->hw.channels_max) { 228 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", 229 codec_dai->name, cpu_dai->name); 230 goto machine_err; 231 }
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Same will cause problems in ALSA also, because nobody is checking whether channel_min/max is zero; it is used in pcm_native.c
http://mailman.alsa-project.org/pipermail/alsa-devel/2007-June/001400.html
On 6/12/07, Nobin Mathew nobin.mathew@gmail.com wrote:
Seems like a problem, Adding to that
if (machine->ops && machine->ops->shutdown) machine->ops->shutdown(substream);
if (platform->pcm_ops->close) platform->pcm_ops->close(substream);
if (cpu_dai->ops.shutdown) cpu_dai->ops.shutdown(substream);
if it is a error condition then above functions are called twice (also in snd_codec_close())
Nobin Mathew
On 6/11/07, Matthieu CASTET matthieu.castet@parrot.com wrote:
Hi,
it seems there is a bug in soc_pcm_open. In some case [1] we are in a error path, but we don't set the ret return value.
This cause bug/crash from alsa core.
Thanks
Matthieu
[1]http://hg-mirror.alsa-project.org/alsa-kernel/file/38926de0e79c/soc/soc-core... if (!runtime->hw.rates) {
218 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", 219 codec_dai->name, cpu_dai->name); 220 goto machine_err; 221 } 222 if (!runtime->hw.formats) { 223 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", 224 codec_dai->name, cpu_dai->name); 225 goto machine_err; 226 } 227 if (!runtime->hw.channels_min || !runtime->hw.channels_max) { 228 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", 229 codec_dai->name, cpu_dai->name); 230 goto machine_err; 231 }
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Tue, 12 Jun 2007 11:21:47 +0530, Nobin Mathew wrote:
Same will cause problems in ALSA also, because nobody is checking whether channel_min/max is zero; it is used in pcm_native.c
http://mailman.alsa-project.org/pipermail/alsa-devel/2007-June/001400.html
Yes, ALSA core layer assumes that the driver shall pass the correct value. Does the patch like below fix the problem?
(BTW, it'd be aprreciated if you can avoid top-citation...)
Takashi
diff -r 640ed49a540d soc/soc-core.c --- a/soc/soc-core.c Tue Jun 12 11:27:46 2007 +0200 +++ b/soc/soc-core.c Tue Jun 12 14:52:25 2007 +0200 @@ -213,6 +213,7 @@ static int soc_pcm_open(struct snd_pcm_s codec_dai->capture.rates & cpu_dai->capture.rates; }
+ ret = -EINVAL; /* passed to machine_err */ snd_pcm_limit_hw_rates(runtime); if (!runtime->hw.rates) { printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
On Tue, 2007-06-12 at 11:21 +0530, Nobin Mathew wrote:
Same will cause problems in ALSA also, because nobody is checking whether channel_min/max is zero; it is used in pcm_native.c
http://mailman.alsa-project.org/pipermail/alsa-devel/2007-June/001400.html
On 6/12/07, Nobin Mathew nobin.mathew@gmail.com wrote:
Seems like a problem, Adding to that
if (machine->ops && machine->ops->shutdown) machine->ops->shutdown(substream);
if (platform->pcm_ops->close) platform->pcm_ops->close(substream);
if (cpu_dai->ops.shutdown) cpu_dai->ops.shutdown(substream);
if it is a error condition then above functions are called twice (also in snd_codec_close())
They should only be called once (in open()) as close() should only be called after the device has successfully opened.
Fwiw, I placed some debug in close just to make sure nothing in the upper layers was calling close when open failed. Everything seems to work as expected.
Liam
participants (4)
-
Liam Girdwood
-
Matthieu CASTET
-
Nobin Mathew
-
Takashi Iwai