Commit d7f910bf authored by Takashi Iwai's avatar Takashi Iwai

ALSA: timer: Wrap with spinlock for queue access

For accessing the snd_timer_user queue indices, we take tu->qlock.
But it's forgotten in a couple of places.

The one in snd_timer_user_params() should be safe without the
spinlock as the timer is already stopped.  But it's better for
consistency.

The one in poll is just a read-out, so it's not inevitably needed, but
it'd be good to make the result consistent, too.
Tested-by: default avatarAlexander Potapenko <glider@google.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 890e2cb5
...@@ -1755,6 +1755,7 @@ static int snd_timer_user_params(struct file *file, ...@@ -1755,6 +1755,7 @@ static int snd_timer_user_params(struct file *file,
if (err < 0) if (err < 0)
goto _end; goto _end;
} }
spin_lock_irq(&tu->qlock);
tu->qhead = tu->qtail = tu->qused = 0; tu->qhead = tu->qtail = tu->qused = 0;
if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) {
if (tu->tread) { if (tu->tread) {
...@@ -1775,6 +1776,7 @@ static int snd_timer_user_params(struct file *file, ...@@ -1775,6 +1776,7 @@ static int snd_timer_user_params(struct file *file,
} }
tu->filter = params.filter; tu->filter = params.filter;
tu->ticks = params.ticks; tu->ticks = params.ticks;
spin_unlock_irq(&tu->qlock);
err = 0; err = 0;
_end: _end:
if (copy_to_user(_params, &params, sizeof(params))) if (copy_to_user(_params, &params, sizeof(params)))
...@@ -2022,10 +2024,12 @@ static unsigned int snd_timer_user_poll(struct file *file, poll_table * wait) ...@@ -2022,10 +2024,12 @@ static unsigned int snd_timer_user_poll(struct file *file, poll_table * wait)
poll_wait(file, &tu->qchange_sleep, wait); poll_wait(file, &tu->qchange_sleep, wait);
mask = 0; mask = 0;
spin_lock_irq(&tu->qlock);
if (tu->qused) if (tu->qused)
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
if (tu->disconnected) if (tu->disconnected)
mask |= POLLERR; mask |= POLLERR;
spin_unlock_irq(&tu->qlock);
return mask; return mask;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment