summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-04-24 07:26:59 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-02 07:53:41 -0700
commit37d11f6e286d975be4a21b02f159ff0594a266f5 (patch)
tree8608362f96d43d6fc6323f2c92a72e51397d2ad3
parent10a249ca58c99e0980383fbc4ec7be7506283b30 (diff)
downloadlinux-stable-37d11f6e286d975be4a21b02f159ff0594a266f5.tar.gz
linux-stable-37d11f6e286d975be4a21b02f159ff0594a266f5.tar.bz2
linux-stable-37d11f6e286d975be4a21b02f159ff0594a266f5.zip
ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device
commit f5e94b4c6ebdabe0f602d796e0430180927521a0 upstream. When get_synthdev() is called for a MIDI device, it returns the fixed midi_synth_dev without the use refcounting. OTOH, the caller is supposed to unreference unconditionally after the usage, so this would lead to unbalanced refcount. This patch corrects the behavior and keep up the refcount balance also for the MIDI synth device. Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index b16dbef04174..899a2b166595 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -363,10 +363,14 @@ get_synthdev(struct seq_oss_devinfo *dp, int dev)
return NULL;
if (! dp->synths[dev].opened)
return NULL;
- if (dp->synths[dev].is_midi)
- return &midi_synth_dev;
- if ((rec = get_sdev(dev)) == NULL)
- return NULL;
+ if (dp->synths[dev].is_midi) {
+ rec = &midi_synth_dev;
+ snd_use_lock_use(&rec->use_lock);
+ } else {
+ rec = get_sdev(dev);
+ if (!rec)
+ return NULL;
+ }
if (! rec->opened) {
snd_use_lock_free(&rec->use_lock);
return NULL;