]> git.itanic.dy.fi Git - linux-stable/commit
ALSA: seq: oss: Fix data-race for max_midi_devs access
authorTakashi Iwai <tiwai@suse.de>
Tue, 23 Aug 2022 07:27:16 +0000 (09:27 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 23 Aug 2022 15:00:12 +0000 (17:00 +0200)
commit22dec134dbfa825b963f8a1807ad19b943e46a56
tree9e735f537f97339d5302da203c887a2359b3ab09
parenta8d302a0b77057568350fe0123e639d02dba0745
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 <abhishek.shah@columbia.edu>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/CAEHB2493pZRXs863w58QWnUTtv3HHfg85aYhLn5HJHCwxqtHQg@mail.gmail.com
Link: https://lore.kernel.org/r/20220823072717.1706-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/oss/seq_oss_midi.c