[alsa-devel] Cannot combine audio devices with more than 64 channels

Takashi Iwai tiwai at suse.de
Fri Jan 27 12:08:15 CET 2017


On Thu, 26 Jan 2017 17:13:50 +0100,
Clemens Ladisch wrote:
> 
> Jörg Müller wrote:
> > I created an .asoundrc with 194 inputs for each card.
> >
> > pcm_multi.c:1060: snd_pcm_multi_open: Assertion `!slave_map[sidxs[i]][schannels[i]]' failed.
> >
> > To me, this looks like a bug.
> 
> --8<---------------------------------------------------------------->8--
> pcm: multi: allocate slave_map dynamically
> 
> Using a fixed-size buffer for an arbitrarily-sized list is not a good idea.
> 
> Signed-off-by: Clemens Ladisch <clemens at ladisch.de>

It turned out that we don't need the array at all.
I'll apply the following cleanup (and fix) patch.  My previous one was
buggy.


thanks,

Takashi

-- 8< --
From: Takashi Iwai <tiwai at suse.de>
Subject: [PATCH] pcm: multi: Drop the fixed slave_map[] in snd_pcm_multi_open()

slave_map[] in snd_pcm_multi_open() is a fixed size array and
obviously we have no overflow check, and eventually the program gets
an error when more than 64 channels are used.

Although we can modify the code to allocate the array dynamically, it
turned out that we can drop the whole slave_map[] thingy in this
function when looking at the code closely.  In the past, it was used
to identify the one-to-many mapping.  But the check was dropped, and
now it's nothing more than a sanity check.

Reported-by: Jörg Müller <joerg.mueller7744 at gmail.com>
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
 src/pcm/pcm_multi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c
index c4b1fba32cac..9e4be7122c0f 100644
--- a/src/pcm/pcm_multi.c
+++ b/src/pcm/pcm_multi.c
@@ -1015,7 +1015,6 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
 	snd_pcm_multi_t *multi;
 	unsigned int i;
 	snd_pcm_stream_t stream;
-	char slave_map[64][64] = { { 0 } };
 	int err;
 
 	assert(pcmp);
@@ -1059,8 +1058,6 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
 		bind->slave_channel = schannels[i];
 		if (sidxs[i] < 0)
 			continue;
-		assert(!slave_map[sidxs[i]][schannels[i]]);
-		slave_map[sidxs[i]][schannels[i]] = 1;
 	}
 	multi->channels_count = channels_count;
 
-- 
2.11.0



More information about the Alsa-devel mailing list