Skip to content

Commit a44ca38

Browse files
tiwaigregkh
authored andcommitted
ALSA: seq: Don't handle loop timeout at snd_seq_pool_done()
commit 37a7ea4a9b81f6a864c10a7cb0b96458df5310a3 upstream. snd_seq_pool_done() syncs with closing of all opened threads, but it aborts the wait loop with a timeout, and proceeds to the release resource even if not all threads have been closed. The timeout was 5 seconds, and if you run a crazy stuff, it can exceed easily, and may result in the access of the invalid memory address -- this is what syzkaller detected in a bug report. As a fix, let the code graduate from naiveness, simply remove the loop timeout. BugLink: http://lkml.kernel.org/r/CACT4Y+YdhDV2H5LLzDTJDVF-qiYHUHhtRaW4rbb4gUhTCQB81w@mail.gmail.com Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e5f20a3 commit a44ca38

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

sound/core/seq/seq_memory.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)
419419
{
420420
unsigned long flags;
421421
struct snd_seq_event_cell *ptr;
422-
int max_count = 5 * HZ;
423422

424423
if (snd_BUG_ON(!pool))
425424
return -EINVAL;
@@ -432,14 +431,8 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)
432431
if (waitqueue_active(&pool->output_sleep))
433432
wake_up(&pool->output_sleep);
434433

435-
while (atomic_read(&pool->counter) > 0) {
436-
if (max_count == 0) {
437-
pr_warn("ALSA: snd_seq_pool_done timeout: %d cells remain\n", atomic_read(&pool->counter));
438-
break;
439-
}
434+
while (atomic_read(&pool->counter) > 0)
440435
schedule_timeout_uninterruptible(1);
441-
max_count--;
442-
}
443436

444437
/* release all resources */
445438
spin_lock_irqsave(&pool->lock, flags);

0 commit comments

Comments
 (0)