ALSA: seq: oss: Fix racy open/close of MIDI devices
authorTakashi Iwai <tiwai@suse.de>
Mon, 12 Jun 2023 12:55:33 +0000 (14:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:42:25 +0000 (09:42 +0200)
commitf24681b8162bd7c707d07c4d0dce0a04f447c326
tree0502c8e6019a9e35e9a5a7192af6301f99844ebd
parentab5c5c10d0668578b40e76faa316a995b316064b
ALSA: seq: oss: Fix racy open/close of MIDI devices

[ Upstream commit 297224fc0922e7385573a30c29ffdabb67f27b7d ]

Although snd_seq_oss_midi_open() and snd_seq_oss_midi_close() can be
called concurrently from different code paths, we have no proper data
protection against races.  Introduce open_mutex to each seq_oss_midi
object for avoiding the races.

Reported-by: "Gong, Sishuai" <sishuai@purdue.edu>
Closes: https://lore.kernel.org/r/7DC9AF71-F481-4ABA-955F-76C535661E33@purdue.edu
Link: https://lore.kernel.org/r/20230612125533.27461-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/core/seq/oss/seq_oss_midi.c