]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
ALSA: fix locking in snd_pcm_open*() and snd_rawmidi_open*()
authorTakashi Iwai <tiwai@suse.de>
Tue, 30 Sep 2008 09:52:57 +0000 (11:52 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Oct 2008 03:22:53 +0000 (20:22 -0700)
commit875e33b0a336ada0441f5305ddc862b354c457cb
treeb4c6a9ced2383f61deeaf732d67558d19b4872f0
parentb7bacf78acade979a96792b302a42c9f9f122246
ALSA: fix locking in snd_pcm_open*() and snd_rawmidi_open*()

Upstream-commit-id: 399ccdc1cd4e92e541d4dacbbf18c52bd693418b

The PCM and rawmidi open callbacks have a lock against card->controls_list
but it takes a wrong one, card->controls_rwsem, instead of a right one
card->ctl_files_rwlock.  This patch fixes them.

This change also fixes automatically the potential deadlocks due to
mm->mmap_sem in munmap and copy_from/to_user, reported by Sitsofe
Wheeler:

  A: snd_ctl_elem_user_tlv(): card->controls_rwsem => mm->mmap_sem
  B: snd_pcm_open(): card->open_mutex => card->controls_rwsem
  C: munmap: mm->mmap_sem => snd_pcm_release(): card->open_mutex

The patch breaks the chain.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
sound/core/pcm.c
sound/core/rawmidi.c