linux/sound/synth/emux
Steven Rostedt (Google) f0a868788f ALSA: Use del_timer_sync() before freeing timer
The current code for freeing the emux timer is extremely dangerous:

  CPU0				CPU1
  ----				----
snd_emux_timer_callback()
			    snd_emux_free()
			      spin_lock(&emu->voice_lock)
			      del_timer(&emu->tlist); <-- returns immediately
			      spin_unlock(&emu->voice_lock);
			      [..]
			      kfree(emu);

  spin_lock(&emu->voice_lock);

 [BOOM!]

Instead just use del_timer_sync() which will wait for the timer to finish
before continuing. No need to check if the timer is active or not when
doing so.

This doesn't fix the race of a possible re-arming of the timer, but at
least it won't use the data that has just been freed.

[ Fixed unused variable warning by tiwai ]

Cc: stable@vger.kernel.org
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20221026231236.6834b551@gandalf.local.home
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-10-27 08:42:08 +02:00
..
emux_effect.c ALSA: synth: Fix assignment in if condition 2021-06-09 17:30:35 +02:00
emux_hwdep.c ALSA: synth: Fix assignment in if condition 2021-06-09 17:30:35 +02:00
emux_nrpn.c ALSA: emux: fix spelling mistakes 2021-07-05 19:34:22 +02:00
emux_oss.c ALSA: seq: oss: Constify snd_seq_oss_callback definitions 2020-01-03 09:24:41 +01:00
emux_proc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
emux_seq.c ALSA: seq: Constify struct snd_midi_op 2020-01-03 09:24:19 +01:00
emux_synth.c ALSA: emux: More constifications 2020-01-05 16:14:46 +01:00
emux_voice.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
emux.c ALSA: Use del_timer_sync() before freeing timer 2022-10-27 08:42:08 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
soundfont.c ALSA: emux: fix spelling mistakes 2021-07-05 19:34:22 +02:00