Skip to content

Commit

Permalink
[ALSA] usb-audio: properly lock hwptr_done accesses
Browse files Browse the repository at this point in the history
USB generic driver
Take the substream lock when reading hwptr_done to avoid a race
condition with the updates in the URB callbacks.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
  • Loading branch information
Clemens Ladisch authored and Jaroslav Kysela committed Aug 30, 2005
1 parent 9624ea8 commit daa150e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sound/usb/usbaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,14 @@ static int wait_clear_urbs(snd_usb_substream_t *subs)
*/
static snd_pcm_uframes_t snd_usb_pcm_pointer(snd_pcm_substream_t *substream)
{
snd_usb_substream_t *subs = (snd_usb_substream_t *)substream->runtime->private_data;
return subs->hwptr_done;
snd_usb_substream_t *subs;
snd_pcm_uframes_t hwptr_done;

subs = (snd_usb_substream_t *)substream->runtime->private_data;
spin_lock(&subs->lock);
hwptr_done = subs->hwptr_done;
spin_unlock(&subs->lock);
return hwptr_done;
}


Expand Down

0 comments on commit daa150e

Please sign in to comment.