OSDN Git Service

pcm: dshare: Fix segfault when not binding channel 0
authorKirill Marinushkin <kmarinushkin@birdec.tech>
Tue, 20 Nov 2018 20:43:44 +0000 (21:43 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 21 Nov 2018 10:01:21 +0000 (11:01 +0100)
commitd3dfef24bf47b0556deed9686d62a0255cace7e8
treefc003f0393a3e814cfce74c5a6a317a596999dce
parent6b058fda9dce8f416774ae54975f5706f3f5a6da
pcm: dshare: Fix segfault when not binding channel 0

Configuration to reproduce:

~~~~
pcm.share_right {
  type dshare
  ipc_key 73
  ipc_perm 0666
  slave {
    pcm "hw:0,0"
  }
  bindings {
    # the seagfault happens when we don't bind channel 0
    1 1
  }
}
~~~~

Execute to reproduce:

~~~~
$ aplay -D plug:share_right test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Segmentation fault
~~~~

For channels whithout binding, values are set to UINT_MAX in function
`snd_pcm_direct_parse_bindings()`:

~~~~
for (chn = 0; chn < count; chn++)
bindings[chn] = UINT_MAX; /* don't route */
~~~~

But, these values are not checked when playing, which causes the segfault.

This commit fixes the issue.

Signed-off-by: Kirill Marinushkin <kmarinushkin@birdec.tech>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_dshare.c