Skip to content

Commit 22dec13

Browse files
committed
ALSA: seq: oss: Fix data-race for max_midi_devs access
ALSA OSS sequencer refers to a global variable max_midi_devs at creating a new port, storing it to its own field. Meanwhile this variable may be changed by other sequencer events at snd_seq_oss_midi_check_exit_port() in parallel, which may cause a data race. OTOH, this data race itself is almost harmless, as the access to the MIDI device is done via get_mdev() and it's protected with a refcount, hence its presence is guaranteed. Though, it's sill better to address the data-race from the code sanity POV, and this patch adds the proper spinlock for the protection. Reported-by: Abhishek Shah <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/CAEHB2493pZRXs863w58QWnUTtv3HHfg85aYhLn5HJHCwxqtHQg@mail.gmail.com Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent a8d302a commit 22dec13

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/core/seq/oss/seq_oss_midi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ snd_seq_oss_midi_clear_all(void)
270270
void
271271
snd_seq_oss_midi_setup(struct seq_oss_devinfo *dp)
272272
{
273+
spin_lock_irq(&register_lock);
273274
dp->max_mididev = max_midi_devs;
275+
spin_unlock_irq(&register_lock);
274276
}
275277

276278
/*

0 commit comments

Comments
 (0)