Skip to content

Commit

Permalink
ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device
Browse files Browse the repository at this point in the history
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: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Apr 25, 2018
1 parent ab3b8e5 commit f5e94b4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sound/core/seq/oss/seq_oss_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f5e94b4

Please sign in to comment.