]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ALSA: timer: Handle disconnection more safely
authorTakashi Iwai <tiwai@suse.de>
Thu, 21 Jan 2016 16:19:31 +0000 (17:19 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:43:17 +0000 (15:43 -0700)
commit797c9acec70c593b2632a57f5e7d392fbb72df06
tree05a3bcae6c834b4ae7fa1e205a867a01b52335ea
parent108ed5082187e3ae107e0edbada9ba2b12a1713b
ALSA: timer: Handle disconnection more safely

Orabug: 23330536

commit 230323dac060123c340cf75997971145a42661ee upstream.

Currently ALSA timer device doesn't take the disconnection into
account very well; it merely unlinks the timer device at disconnection
callback but does nothing else.  Because of this, when an application
accessing the timer device is disconnected, it may release the
resource before actually closed.  In most cases, it results in a
warning message indicating a leftover timer instance like:
   ALSA: timer xxxx is busy?
But basically this is an open race.

This patch tries to address it.  The strategy is like other ALSA
devices: namely,
- Manage card's refcount at each open/close
- Wake up the pending tasks at disconnection
- Check the shutdown flag appropriately at each possible call

Note that this patch has one ugly hack to handle the wakeup of pending
tasks.  It'd be cleaner to introduce a new disconnect op to
snd_timer_instance ops.  But since it would lead to internal ABI
breakage and it eventually increase my own work when backporting to
stable kernels, I took a different path to implement locally in
timer.c.  A cleanup patch will follow at next for 4.5 kernel.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=109431
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b309c8bf5a4a524b30f9e4013828eed9dbea1e5c)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
sound/core/timer.c