Skip to content

Commit 451e9d9

Browse files
tiwaisashalevin
authored andcommitted
ALSA: timer: Fix leftover link at closing
[ Upstream commit 094fd3b ] In ALSA timer core, the active timer instance is managed in active_list linked list. Each element is added / removed dynamically at timer start, stop and in timer interrupt. The problem is that snd_timer_interrupt() has a thinko and leaves the element in active_list when it's the last opened element. This eventually leads to list corruption or use-after-free error. This hasn't been revealed because we used to delete the list forcibly in snd_timer_stop() in the past. However, the recent fix avoids the double-stop behavior (in commit [f784beb: ALSA: timer: Fix link corruption due to double start or stop]), and this leak hits reality. This patch fixes the link management in snd_timer_interrupt(). Now it simply unlinks no matter which stream is. BugLink: http://lkml.kernel.org/r/CACT4Y+Yy2aukHP-EDp8-ziNqNNmb-NTf=jDWXMP7jB8HDa2vng@mail.gmail.com Reported-by: Dmitry Vyukov <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b35f45f commit 451e9d9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,8 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
744744
ti->cticks = ti->ticks;
745745
} else {
746746
ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
747-
if (--timer->running)
748-
list_del_init(&ti->active_list);
747+
--timer->running;
748+
list_del_init(&ti->active_list);
749749
}
750750
if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
751751
(ti->flags & SNDRV_TIMER_IFLG_FAST))

0 commit comments

Comments
 (0)